Docker Community Forums

Share and learn in the Docker community.

Multiple container of the same software

Hi everyone, How can I create multiple containers of the same software on one host? In the dockerfile through expose instruction I have specified a range of 100 ports, the second or third container to be reached via the host’s public IP I have to customize the image and specify another range of ports, or map to other ports of the host in the process of creating the container?

Short answer: yes
Slightly longer one: it depends … :smiley:

Yes you can spin-up docker containers with the same software as many as you like. But you can only assign a port (or portrange) once to the host’s IP.
Let’s say you’ve an image called superCoolApp. That uses on port 80 inside the container. If you run that container you’ll need to “map” this port to the host. If you start another container that also use this port, you’ll either need to assign it to a different port or to another IP (if your host has multiple IP’s …)

So the first Container would be:

docker run -d -p 80:80 superCoolApp

The second Container might be:

docker run -d -p 81:80 superCoolApp

The third …

docker run -d -p 82:80 superCoolApp

… you get the idea … :wink: