deef
deef

Reputation: 4770

How to build and start containers on multiple docker machines

I have to rebuild an image and stop/run new containers on a large number of docker machines. What is the best way to do this in an automated way?

Right now I am doing

eval $(docker-machine env docker-host-1)

docker stop some-container

docker build -t my-image .

docker run -d my-image

for each host but this is very time consuming.

Upvotes: 0

Views: 56

Answers (1)

charli
charli

Reputation: 1778

Building

Build the image only once and push it to a registry. You can use the public registry of Docker or use a private one.

docker push $DOCKERHUB_USER/my-image:latest

Then you just use that image from your docker hosts:

docker run -d $DOCKERHUB_USER/my-image:latest

Upgrade

You need an orchestrator to ease management. Take a look to Docker Swarm, Kubernetes, Openshift or Rancher. In a nutshell, the orchestrator will schedule and run your containers on the docker hosts. If you want to upgrade, just create the image with a different tag and change it in the service definition. The orchestrator will roll out the upgrade for you.

Upvotes: 3

Related Questions