Docker Community Forums

Share and learn in the Docker community.

How to get many instance of the same docker image

docker

(Marwenb) #1

Hello every one,

I’m new to Docker , and i’m wondering how to get two or three instance of the same docker image.

As a result when I execute docker ps i get :

 Container-------- Image-------- PORT
 web-app-dev-01 ------- WEB-APP ----- 8082:80 
 web-app-dev-02 --------- WEB-APP ---- 80883:80

Each instance have a unique port and configuration.

Thank you very much for your help.


(Think) #2

there is no port 80883, so I guess this is just handwritten. :slight_smile:

just run it multiple times

docker run -d -p 8082:80 YOUR_IMAGE
and
docker run -d -p 8083:80 YOUR_IMAGE

Then both containers run in the background.


(Marwenb) #3

Thank you for your response , but i need just to confirm the result:

#docker ps
CONTAINER ID IMAGE COMMAND PORTS NAMES
xxxxxxxxxxxx nginx xxxxxxxxx 0.0.0.0:7070->80 name
xxxxxxxxxxxx nginx xxxxxxxxx 0.0.0.0:7060->80 name1

Is like this one?


(Think) #4

yes, looks good.
and you should be able to check your two webservers on http://localhost:7070 and http://localhost:7060


(Marwenb) #5

OK , thank you for your response.