Docker Community Forums

Share and learn in the Docker community.

How to create and run n containers form an image


(Vishwamanchala) #1

Hi,
I would like to start n containers from an image. For example, when run command issued in docker CLI, daemon pulls an image, creates a single container from the image and runs the container. Similarly I want to create n number of containers from same image and start the containers.
Please assist me how to proceed.

Thanks,
Vishwanath


(Jerry Baker) #2

Hi vishwamanchala,

For simple configurations you can use a bash for loop:

for i in {1..5}; do docker run -d nginx; done

but if you need more control over your stack I’d use Docker Compose for launching. See: http://docs.docker.com/compose/


(Crosen188) #3

You could also deploy a scalable group of containers on IBM Bluemix (http://bluemix.net/), which gives you the ability to upload any Docker image and control the quantity of instances.


(Meir Wahnon) #4

Try to look at : http://www.cloudslang.io/
It has parallel capability to launch containers…


(Vishwamanchala) #5

Thanks Jerry.
I have tried the script but it is launching only one container.

Thanks,
Vishwanath


(Vishwamanchala) #6

Now I am able to run. This is a bash issue.

Thanks,
Vish


(Vishwamanchala) #7

Hi,
Could anyone plz answer for my post Container not getting started after start command issued

Thanks,
Vishwanath