Docker container version label goes stale after WUD recreates a container
WUD's Docker trigger replaces containers by cloning the existing container configuration, then pulling the new image and recreating the container. Docker container labels are immutable after creation, so the cloned container keeps the old org.opencontainers.image.* labels even though it now runs a newer image. That's why the container reports an old version while the image reports the new one.
Suggestion: when recreating a container, merge the new image's labels into the container labels (or add an option like WUD_TRIGGER_DOCKER_*_REFRESH_LABELS=true). That would keep the container's version label in sync with the image actually running.
Implementation sketch
- New trigger option (env):
WUD_TRIGGER_DOCKER_<name>_REFRESH_LABELS=true - Optional whitelist:
WUD_TRIGGER_DOCKER_<name>_REFRESH_LABELS_PREFIX=org.opencontainers.image. In
Docker.js, afterpullImage()and beforecreateContainer():
Build `imageLabels = imageInspect.Config?.Labels || {}` and merge into `containerToCreateInspect.Config.Labels` only for whitelisted prefixes, leaving other labels untouched.const image = await dockerApi.getImage(newImage) const imageInspect = await image.inspect()
Conflict policy
- Only update keys in the whitelist; do not override other labels.
- If the container already has a key in the whitelist, overwrite with the image's value (so version labels refresh).
This keeps existing behaviour by default and avoids clobbering anything else.
Originally requested by .qed in Discord #ideas.
0 Comments
No comments yet. Be the first to share your thoughts!
