- Stef Smeets - Research Software Engineer/
- Posts/
- TIL how to update docker compose images the right way/
TIL how to update docker compose images the right way
Every time I want to update my docker images, I’m a bit confused about the best way to do it. I run all my images using docker compose. Sometimes I want to update a single image to try a new feature, and sometimes I update all of them at once.
The reason for this post is that the last time when I tried to update all my images, it did not go as planned. I updated all images by removing the running images, and then restarting them.
When you remove an image and then restart your container, docker will always pull the latest image version. While this usually works, it gave me issues this time because I run adguard as my DNS server. Removing adguard meant that the image got taken down before the new image was available. No DNS means no internet1. No internet means no new docker images to pull. Not ideal. 😅
I find it works better to first pull the new image(s) and then restarting the containers:
|
|
To pull the image for a specific service:
|
|
or by its image name directly:
|
|
Optionally, remove old unused images:
|
|
Well, mostly. At least firefox caches DNS requests, so my frequently visited sites are still accessible somehow. ↩︎