Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a Docker Image

Tags:

How do I update a docker image when the official repository is updated?

How do I update custom images when I change the DockerFile, or the Dockerfile contains time sensitive informations?

Is it better practice to build new images, or to rebuild exiting ones?

What's the best way to rebuild an existing image?

What's the best way to differentiate multiple builds of the same image?

like image 680
Mascarpone Avatar asked Aug 28 '14 14:08

Mascarpone


People also ask

Does Docker run update image?

Docker images within a running container do not update automatically. Once you have used an image to create a container, it continues running that version, even after new releases come out. It is recommended to run containers from the latest Docker image unless you have a specific reason to use an older release.

How do I keep my Docker containers updated?

# Update your tags manually as needed When a new version comes out, update the tag in your docker-compose. yml , docker-compose pull , and then restart the container ( docker-compose down && docker-compose up -d ). This is simple, and robust, and means nothing will update without you knowing.

How do I push the update image to Docker hub?

To push an image to Docker Hub, you must first name your local image using your Docker Hub username and the repository name that you created through Docker Hub on the web. You can add multiple images to a repository by adding a specific :<tag> to them (for example docs/base:testing ).


1 Answers

How do I update a docker image when the official repository is updated?

If you are using the Docker Hub to create an automated build, then you can add a Repository Link which will rebuild your repo when the linked repo updates.

If you want to do the builds yourself, you could create a hacky workaround to get the notification via a link as above and rebuild a trivial repo, then use a Web Hook to notify your build system of the change.

How do I update custom images when I change the DockerFile, or the Dockerfile contains time sensitive informations?

If you are using the Docker Hub for an automated build, then changes to your BitBucket or GitHub source repo, including Dockerfile changes, will trigger a new build.

If you're building images yourself, just type docker build . in the directory where your Dockerfile resides. You can use --no-cache to force a completely fresh rebuild

Is it better practice to build new images, or to rebuild exiting ones?

That depends on who is using your images. When you build, the result is always a new image, but how you tag the result can make it seem like a replacement for the old image or something new.

What's the best way to differentiate multiple builds of the same image?

Use the :tag feature in the name, eg

ubuntu:latest ubuntu:12.04 ubuntu:14.04 ... 

see https://registry.hub.docker.com/_/ubuntu/ for a complete list of all the variations on the "ubuntu" image. See the tag documentation for the complete format for a friendly image name. All tags and names are aliases for the canonical image name, that long UUID-looking string when you run docker images --no-trunc.

like image 164
Andy Avatar answered Oct 14 '22 09:10

Andy