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: pull_policy every_12h makes Compose check for new images on a schedule

Docker
~/tips/tip-compose-pull-policy-every

pull_policy: every_12h

Tells Compose how often to check the registry for a newer image, such as every 12 hours.

By default Compose pulls an image only if it is missing, so a stack can run an old image for months. The pull_policy attribute lets you decide how often it looks.

The container specification lists the values. always pulls every time, never relies on the cached image and reports a failure if there is none, and missing pulls only when the image is not in the cache. missing is the default when the build specification is not also used, and the latest tag is always pulled even with it. build makes Compose build the image, and rebuild it if it is already present.

Then the time-based ones: daily checks the registry if the last pull was more than 24 hours ago, weekly does the same with seven days, and every_<duration> takes your own. Units are weeks, days, hours, minutes and seconds (w, d, h, m, s), and they can be combined.

services:
  app:
    image: example/app:1.0
    pull_policy: every_12h

I like daily for a pinned tag that the maintainer might rebuild with security fixes, since you get the new base image without ever typing pull.

The check happens when you run docker compose up, not in the background. Nothing watches the registry for you, so a stack that is never started or recreated never updates. Even when a new image is pulled, the running container only changes when Compose recreates it. A moving tag can still change your setup, so I would use this with version tags.

Further reading: Compose container specification: pull_policy

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