Skip to content

docker compose up no longer recreates container if image is updated #9259

Closed

Description

@csmith

Description

As of v2.3.0, running docker compose up -d will no longer recreate containers whose images have been updated. Previously a docker compose pull; docker compose up -d would ensure all containers in the compose file were running the latest images.

Steps to reproduce the issue:

  1. Create a simple compose file:
version: '3.5'
services:
  test:
    image: some-registry/image
    restart: always
  1. Start the container with docker compose up -d
  2. Push a new image to the registry
  3. docker compose pull
  4. docker compose up -d

Describe the results you received:

The pull step pulls the updated image, but up -d does nothing.

Describe the results you expected:

The pull step pulls the updated image, then up -d recreates the container using the new image.

Additional information you deem important (e.g. issue happens only occasionally):

Bisect shows b5b8e7a as the first bad commit. In this example I am running a container with a version=8 label, but have pushed a new image to the registry with version=9:

$ git checkout b5b8e7a116ccd8a9183c6661589b1c051fca17d9
Previous HEAD position was 16914e37 Bump compose-go 1.1.0
HEAD is now at b5b8e7a1 exclude com.docker.compose.image label from service hash
$ docker-compose pull; go run ./cmd/ up -d; docker inspect compose-test-1 | grep '"version"'
[+] Running 1/0
 ⠿ test Pulled                                                                                                                                                            0.1s
[+] Running 1/0
 ⠿ Container compose-test-1  Started                                                                                                                                      0.0s
                "version": "8"

$ git checkout b5b8e7a116ccd8a9183c6661589b1c051fca17d9^                                    
Previous HEAD position was b5b8e7a1 exclude com.docker.compose.image label from service hash
HEAD is now at f7a6c3bc Bump github.com/containerd/containerd from 1.5.8 to 1.6.0
$ docker-compose pull; go run ./cmd/ up -d; docker inspect compose-test-1 | grep '"version"'
[+] Running 1/0
 ⠿ test Pulled                                                                                                                                                            0.1s
[+] Running 1/1
 ⠿ Container compose-test-1  Started                                                                                                                                      0.4s
                "version": "9"

You can see with commit b5b8e7a the container isn't recreated (it takes no time and still has the version=8 label) but as of the commit immediately prior to that the container is recreated as expected.

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
  compose: Docker Compose (Docker Inc., 2.3.0)

Server:
 Containers: 591
  Running: 67
  Paused: 0
  Stopped: 524
 Images: 1121
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1e5ef943eb76627a6d3b6de8cd1ef6537f393a71.m
 runc version: v1.1.0-0-g067aaf85
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.7-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 62.79GiB
 Name: hetzner2.fi.929w.net
 ID: G7J4:PHCS:XKMI:GIGZ:E5J4:IDDW:3CAF:UCDG:SV3Y:VZGO:ERHR:LSZV
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Activity

  1. csmith commented on Mar 9, 2022

    @csmith
    Author
  2. StewGoin commented on Mar 10, 2022

    @StewGoin

    Also seeing this behavior on Debian 11 w/ docker-compose from this project and docker repo from docker.com.

    Output of my docker info:

     Context:    default
     Debug Mode: false
     Plugins:
      app: Docker App (Docker Inc., v0.9.1-beta3)
      buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
      scan: Docker Scan (Docker Inc., v0.12.0)
    
    Server:
     Containers: 23
      Running: 23
      Paused: 0
      Stopped: 0
     Images: 25
     Server Version: 20.10.12
     Storage Driver: overlay2
      Backing Filesystem: extfs
      Supports d_type: true
      Native Overlay Diff: true
      userxattr: false
     Logging Driver: json-file
     Cgroup Driver: systemd
     Cgroup Version: 2
     Plugins:
      Volume: local
      Network: bridge host ipvlan macvlan null overlay
      Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
     Swarm: inactive
     Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: 9cc61520f4cd876b86e77edfeb88fbcd536d1f9d
     runc version: v1.0.3-0-gf46b6ba
     init version: de40ad0
     Security Options:
      apparmor
      seccomp
       Profile: default
      cgroupns
     Kernel Version: 5.10.0-12-amd64
     Operating System: Debian GNU/Linux 11 (bullseye)
     OSType: linux
     Architecture: x86_64
     CPUs: 8
     Total Memory: 31.32GiB
     Name: filer
     ID: V33M:4D6B:YUGM:UFFJ:D354:R6RK:5NII:YKUU:6ZQC:NP25:5ILJ:IUTE
     Docker Root Dir: /var/lib/docker
     Debug Mode: false
     Username: stewgoin
     Registry: https://index.docker.io/v1/
     Labels:
     Experimental: false
     Insecure Registries:
      127.0.0.0/8
     Live Restore Enabled: false```
    
  3. dtcooper commented on Mar 10, 2022

    @dtcooper

    Observing this behaviour on Ubuntu 20.04 as well. Rolling back to version 2.2.3 (latest pre-2.3.x version) fixes the problem for me.

  4. ndeloof commented on Mar 10, 2022

    @ndeloof
    Contributor

    Looking into this ...

  5. self-assigned this
    on Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions