Skip to content

[BUG] Always recreate container, even if the instructions haven't changed. #13944

Description

@DJLebedev

Description

Always recreate container, even if the instructions haven't changed.

Steps To Reproduce

Debian 13

Create docker-compose.yml

services:
  hello-world:
    build: docker/hello-world
    restart: unless-stopped
    ports:
      - "80:80"

Create docker/hello-world/Dockerfile

FROM wordpress:php8.4-fpm

Execute command docker compose up -d --build and repeate this command. It always recreate container, but nothing changed.

bnovo@pms-ui-1:~$ docker compose up -d --build
[+] Building 10.2s (7/7) FINISHED                                                                                     
 => [internal] load local bake definitions                                                                       0.0s
 => => reading from stdin 528B                                                                                   0.0s
 => [internal] load build definition from Dockerfile                                                             0.0s
 => => transferring dockerfile: 548B                                                                             0.0s
 => [internal] load metadata for docker.io/library/wordpress:php8.4-fpm                                          9.8s
 => [internal] load .dockerignore                                                                                0.0s
 => => transferring context: 2B                                                                                  0.0s
 => CACHED [1/1] FROM docker.io/library/wordpress:php8.4-fpm@sha256:a25cb218dc9f6cffb86eecb50829f60b6e60b93e29b  0.0s
 => => resolve docker.io/library/wordpress:php8.4-fpm@sha256:a25cb218dc9f6cffb86eecb50829f60b6e60b93e29bb596b81  0.0s
 => exporting to image                                                                                           0.2s
 => => exporting layers                                                                                          0.0s
 => => exporting manifest sha256:8f4c6388abcce3123e8fbad2e94c2fb56054d638d03f068508f46e343d4fd0b9                0.0s
 => => exporting config sha256:dde371cee956ed916fb87c8c0fa25a86378e0fb02df6b9272c0ee5aaaa58b4a1                  0.0s
 => => exporting attestation manifest sha256:68c6384b931e94ed4ac42dd15e707a5ebff75f8f2b7be46d4f508bd4f1fa2a86    0.0s
 => => exporting manifest list sha256:e3dd9ab83b43a4637794e69e050d2eb03f7c1d1ea884bcae8c6626397919ab0d           0.0s
 => => naming to docker.io/library/bnovo-hello-world:latest                                                      0.0s
 => => unpacking to docker.io/library/bnovo-hello-world:latest                                                   0.0s
 => resolving provenance for metadata file                                                                       0.0s
[+] up 2/2
 ✔ Image bnovo-hello-world       Built                                                                           10.2s
 ✔ Container bnovo-hello-world-1 Started                                                                          0.4s
bnovo@pms-ui-1:~$ docker compose up -d --build
[+] Building 0.9s (7/7) FINISHED                                                                                      
 => [internal] load local bake definitions                                                                       0.0s
 => => reading from stdin 528B                                                                                   0.0s
 => [internal] load build definition from Dockerfile                                                             0.0s
 => => transferring dockerfile: 548B                                                                             0.0s
 => [internal] load metadata for docker.io/library/wordpress:php8.4-fpm                                          0.6s
 => [internal] load .dockerignore                                                                                0.0s
 => => transferring context: 2B                                                                                  0.0s
 => CACHED [1/1] FROM docker.io/library/wordpress:php8.4-fpm@sha256:a25cb218dc9f6cffb86eecb50829f60b6e60b93e29b  0.0s
 => => resolve docker.io/library/wordpress:php8.4-fpm@sha256:a25cb218dc9f6cffb86eecb50829f60b6e60b93e29bb596b81  0.0s
 => exporting to image                                                                                           0.1s
 => => exporting layers                                                                                          0.0s
 => => exporting manifest sha256:8f4c6388abcce3123e8fbad2e94c2fb56054d638d03f068508f46e343d4fd0b9                0.0s
 => => exporting config sha256:dde371cee956ed916fb87c8c0fa25a86378e0fb02df6b9272c0ee5aaaa58b4a1                  0.0s
 => => exporting attestation manifest sha256:d43e6d5ae2f3397573ed3b6553c2993eabb30badb7e927376ce85100deba880e    0.0s
 => => exporting manifest list sha256:a9b2e3fa9898415132cfae4bb2eadbc7bc769ea4bcd15f2e37ab0850c03a83fd           0.0s
 => => naming to docker.io/library/bnovo-hello-world:latest                                                      0.0s
 => => unpacking to docker.io/library/bnovo-hello-world:latest                                                   0.0s
 => resolving provenance for metadata file                                                                       0.0s
[+] up 2/2
 ✔ Image bnovo-hello-world       Built                                                                            0.9s
 ✔ Container bnovo-hello-world-1 Started  

If I downgrade the Docker version to 28.5.2, the behavior becomes correct.

Compose Version

Docker Compose version v5.3.1

Docker Environment

Client: Docker Engine - Community
 Version:    29.6.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.35.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.3.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 2
 Server Version: 29.6.1
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 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 splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e53c7c1516c3b2bff98eb76f1f4117477e6f4e66
 runc version: v1.3.6-0-g491b69ba
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.95+deb13-amd64
 Operating System: Debian GNU/Linux 13 (trixie)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.927GiB
 Name: pms-ui-1
 ID: eb026693-3624-48c9-85f9-0c15b9e34f5d
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables
  EnableUserlandProxy: true
  UserlandProxyPath: /usr/bin/docker-proxy

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions