Skip to content

[BUG] config --hash return incorrect hash value for containers with depends_on #10907

@papegaaij

Description

@papegaaij

Description

The hash computed by docker compose config --hash service does not match the hash that is actually used when creating the container. In our setup we compare the hash generated by config --hash with the hash set on the container to detect if its config is stale. This used to work fine until compose 2.19. docker compose up -d does not recreate the container, but the value of the label does not match the value computed by config --hash.

Steps To Reproduce

Use the following docker-compose.yml:

version: '2'
services:
  test-container:
    container_name: "test-container"
    image: "redis:alpine"
  test-container-2:
    depends_on: ["test-container"]
    container_name: "test-container-2"
    image: "redis:alpine"

Run the following commands and observe the different values:

docker compose up -d
docker compose config --hash test-container-2
docker inspect test-container-2 -f '{{index .Config.Labels "com.docker.compose.config-hash"}}'

Compose Version

Docker Compose version v2.19.1

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.19.1
    Path:     /usr/local/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 9
  Running: 9
  Paused: 0
  Stopped: 0
 Images: 9
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 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 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 4.18.0-477.21.1.el8_8.x86_64
 Operating System: AlmaLinux 8.8 (Sapphire Caracal)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 6.783GiB
 Name: tkh-server1.keyhub-test-nw
 ID: da84eca3-73fd-42ea-9e3c-d56aa94d8c4f
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: true

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions