Updating Postgres Image Causes Other Containers to Use Untagged (<none>) Image

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

  1. This creates disk space issues as I’m essentially duplicating images on my system
  2. I can’t remove these dangling images because they’re still being used by running containers
  3. 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!

Pulling a Docker image will update the local image. It will not influence any running container.

If you want to upgrade containers, you need to re-create them with the new image and tag. Then you can prune old image files.

There are tools like watchtower that automatically re-create containers when a new image is available. Not sure if watchtower is still the latest and greatest, it hasn’t been updated for 2 years.