

- #HOW TO LISTEN TO DOCKER NETWORK MODE HOST HOW TO#
- #HOW TO LISTEN TO DOCKER NETWORK MODE HOST UPDATE#
Also the containers you create this way are not easy to scale. Thus you have to create an image per port and this might not be what you want. You cannot run the same image on multiple ports. Īnd run them like docker run -dit -network host -name my-running-app-01 smeetsm/httpdport84:2.4ĭocker run -dit -network host -name my-running-app-02 smeetsm/httpdport85:2.4ĭocker run -dit -network host -name my-running-app-03 smeetsm/httpdport86:2.4 ĭocker build -build-arg PORT=86 -t smeetsm/httpdport86:2.4. ĭocker build -build-arg PORT=85 -t smeetsm/httpdport85:2.4. docker build -build-arg PORT=84 -t smeetsm/httpdport84:2.4. If you want containers running on multiple ports, you’d need multiple images. Drawback of this is that you build the image specifically for running on a single port. This allows you to build a container for running on a specific port. Īnd run it like: docker run -dit -network host -name my-running-app-01 smeetsm/httpd:2.4 You can build this like: docker build -build-arg PORT=84 -t smeetsm/httpd:2.4. RUN sed -ri "s/^Listen 80/Listen $PORT/g" /usr/local/apache2/conf/nf You could create your own Dockerfile and use an ARG (argument) such as below: FROM httpd:2.4 Using Docker host networking Image per port

#HOW TO LISTEN TO DOCKER NETWORK MODE HOST HOW TO#
At the end of the post I’ll give some tips on how to test connectivity between containers. I’ll describe several features of the different solutions and consequences for connectivity / host lookup options. In this blog I’ll explain 2 mechanisms by which you can expose library/httpd on different ports using host networking and how you can do the same using bridged networking. Suppose you want to use the host networking feature and want to run library/httpd:2.4 on different ports, how would you do this?
#HOW TO LISTEN TO DOCKER NETWORK MODE HOST UPDATE#
When using images like library/httpd:2.4, you don’t have the option to update the port on which it runs it runs by default on port 80. When using the Docker host networking, you don’t have the option to create port mappings. Docker provides different networking options.
