Reputation: 45
I have 2 machines(separate hosts) running docker and I am using the same image on both the machines. How do I keep both the images in sync. For eg. suppose I make changes to the image in one of the hosts and want the changes to reflect in the other host as well. I can commit the image and copy the image over to the other host. Is there any other efficient way of doing this??
Upvotes: 3
Views: 5723
Reputation: 25152
Some ways I can think of:
the workflow here is:
docker commit
, docker push
docker pull
.tar
filethe workflow here is:
docker save
docker load
Dockerfile
and by building the image againthe workflow here is:
Dockerfile
together with your code / files requireddocker build
to create a new image.docker build
the imageyou can see a video here: docker.com/use-cases/cicd
Keep in mind that containers
are considered to be ephemeral. This means that updating an image
inside another host will then require:
stop
and remove
any old container (running with the outdated image)run
a new one (with the updated image)I quote from: Best practices for writing Dockerfiles
General guidelines and recommendations
Containers should be ephemeral
The container produced by the image your Dockerfile defines should be as ephemeral as possible. By “ephemeral,” we mean that it can be stopped and destroyed and a new one built and put in place with an absolute minimum of set-up and configuration.
Upvotes: 4
Reputation: 5550
You can perform docker push
to upload you image to docker registry
and perform a docker pull
to get the latest image from another host.
For more information please look at this
Upvotes: 0