top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Docker: How I can host multiple docker based web servers in same host machine ?

+3 votes
742 views

I have one host machine and want to run multiple docker containers and each container I want to run different web servers.
How I can achieve this ? Sharing the steps would be good enough for me to proceed. Thanks in advance.

posted Aug 20, 2017 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
have you tried docker compose?

1 Answer

0 votes

Hi Vikram, I have run two containers on the different web server, Here I have used nginx alpine image only and running it on two containers on the same host machine.

docker run -d -p 8080:80 --name=nginxone nginx:alpine

localhost:8080

and change the port to 8081 to up another container of nginx.

docker run -d -p 8081:80 --name=nginxtwo nginx:alpine

localhost:8081

apart from that, you can create your own network and communication between these two.

answer Jan 23, 2018 by Shivam Kumar Pandey
Thanks Shivam to share your knowledge. What I understood from your answer is that we can run multiple web server docker containers on the same host machine but   for each web server docker container, a different port need to be assigned. In your example. One web server would be accessed by using the URL format <host machine ip addrees>:8080 and while the other web server would be accessed by using the URL format <host name ip address>:8081. But I want to access both the web server without specifying port number explicitly. Is it possible ?
Similar Questions
+1 vote

Is it possible multiple docker containers each one running web server and listening on the same port, mapped to the same host machine port ? One possible solution to multiple IPs at the host machine and the port exposed by each container is mapped to different ip and standard port 80. This solution would not be feasible in case number of containers increases in the same host and a new IP need to be assigned at host machine for each container.

+1 vote

There are multiple cases:
1. A number of containers have been launched in the same host. how these container communicate to each other
2. Out of "x" numbers of containers in the same host, I want to enable communication between two specific containers. How I can achieve this ?
3. Containers have been launched into different hosts machine and I want to enable communication between these containers. What are the options available ?

+1 vote

I know docker client is used to launch docker containers on docker host. Which protocol is used between docker client and docker host ? Is it necessary docker client run on the same host in which docker client run ?

...