FG
☁️ Cloud & DevOpsDocker

docker-compose up doesn't pull down latest image if the image exists locally

Freshabout 19 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

It would be nice if there were an option to check for new versions of images when running `docker-compose up`. We already have this functionality with `docker build --pull` as was discussed here https://github.com/docker/docker/issues/4238 and there is an open issue to bring `--pull` to `docker run` here https://github.com/docker/docker/issues/13331. I propose adding `--pull` to `up` to always attempt to pull a newer version of the images in the compose file.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Add --pull option to docker-compose up for latest image retrieval

Medium Risk

Docker Compose does not automatically check for newer versions of images that exist locally. When running 'docker-compose up', it uses the local cached image if available, which may not be the latest version. This behavior can lead to outdated containers being run, especially in environments where images are frequently updated.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Modify docker-compose command

    Add the proposed '--pull' option to the 'docker-compose up' command to ensure it checks for and pulls the latest version of images before starting the containers.

    bash
    docker-compose up --pull
  2. 2

    Update docker-compose.yml

    Ensure that your 'docker-compose.yml' file is configured correctly and that the images specified are set to the correct tags or 'latest' to facilitate pulling the newest versions.

    yaml
    version: '3'
    services:
      app:
        image: your-image:latest
  3. 3

    Test the new command

    Run the modified command in your terminal to verify that the latest images are being pulled. Observe the output for any messages indicating that images are being updated.

    bash
    docker-compose up --pull
  4. 4

    Verify container versions

    After running the command, check the running containers to confirm that they are using the latest images. Use 'docker ps' to list running containers and 'docker inspect <container_id>' to check the image version.

    bash
    docker ps
    
    docker inspect <container_id>

Validation

To confirm the fix worked, ensure that the output of 'docker-compose up --pull' indicates that newer images were pulled. Additionally, verify the running containers are using the expected latest images by inspecting their details.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

dockerdocker-composecontainers