Hello Docker Community,
I’m facing an issue when updating a shared postgres:16
image used by multiple containers. Here’s the problem:
Scenario:
- Multiple containers rely on the same
postgres:16
image. - When I update one container via
docker-compose up
, the new image is pulled if an update is available, and the old one becomes<none>
and is still in use by other containers. - Result: Other containers still reference the old (now untagged) image, leading to inconsistency.
- docker compose file:
name: ${DOCKER_NAME}
services:
main:
container_name: ${DOCKER_NAME}
image: postgres:16
Problem Statement
- This creates disk space issues as I’m essentially duplicating images on my system
- I can’t remove these dangling images because they’re still being used by running containers
- The containers using the old image continue running with it, not benefiting from the updates in the new image
Questions:
- How do others manage shared base images across multiple containers?
- Are there best practices to prevent legacy containers from referencing untagged images?
Has anyone solved this problem elegantly? I’d appreciate any guidance on best practices or tools that could help automate this process while minimizing service disruption.
Thank you!