brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker tag the running image as rollback before you pull an update

Docker
~/tips/tip-docker-tag-rollback-before-pull

docker tag example/app:latest example/app:rollback

Keep the old image under a second tag so you can go back after a bad update.

When you pull a new latest, the old image loses its tag and becomes a nameless dangling image that the next prune removes. One extra tag before the pull keeps it findable.

docker tag example/app:latest example/app:rollback
docker compose pull app
docker compose up -d app

docker tag creates a second name for the same image ID. It costs no disk space. If the update misbehaves, point the service at example/app:rollback (or retag it as latest) and recreate the container, and you are back on the old version in seconds, without needing the registry.

I like this for images that only publish latest, where you cannot simply go back to a version number.

An image rollback is not a data rollback. If the new version migrated the database or changed files in its volume on first start, the old version may refuse to run on that data. For apps with a database, I would stop the container and back up the volume before the pull, not after. Also clean up the rollback tags once the new version has proven itself, because a tagged image is never removed by docker image prune and old ones quietly pile up.

Further reading: docker image tag

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link