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??
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
Some ways I can think of:
1. with a Docker registry
the workflow here is:
docker commit
,docker push
docker pull
2. by saving the image to a
.tar
filethe workflow here is:
docker save
docker load
3. with a
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 image4. CI/CD pipeline
you can see a video here: docker.com/use-cases/cicd
Keep in mind that
containers
are considered to be ephemeral. This means that updating animage
inside another host will then require:stop
andremove
any old container (running with the outdated image)run
a new one (with the updated image)I quote from: Best practices for writing Dockerfiles
You can perform
docker push
to upload you image todocker registry
and perform adocker pull
to get the latest image from another host.For more information please look at this