Skip to content

[BUG] docker compose up -d will always rebuild the container if the docker-compose.yaml file has been modified once #10370

@yangjinheng

Description

@yangjinheng

Description

docker compose up -d will always rebuild the container if the docker-compose.yaml file has been modified once

Steps To Reproduce

  1. Modify docker-compose.yaml
  2. docker-compose up -d
  3. docker-compose up -d
  4. Observing the modified service will find that it is still recreated the second time

Compose Version

Docker Compose version v2.16.0

Docker Environment

Docker Compose version v2.16.0
root@quick08v:~/deploy# docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.16.0)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 30
  Running: 27
  Paused: 0
  Stopped: 3
 Images: 87
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-132-generic
 Operating System: Ubuntu 20.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 32
 Total Memory: 62.9GiB
 Name: quick08v.mm.bjmc.qianxin-inc.cn
 ID: CDYB:XGIH:4LAR:LUQ2:IEHC:AV5F:FPVS:HDHD:C2H5:6BSJ:2CZL:JUBP
 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
 Registry Mirrors:
  https://reg-mirror.qiniu.com/
  http://f1361db2.m.daocloud.io/
 Live Restore Enabled: true

WARNING: No swap limit support

Anything else?

I tried printing them before hashing and found that com.docker.compose.replace is involved in hashing

mustRecreate--------------------------------------------
depends_on:
  mysql:
    condition: service_started
deploy:
  replicas: 1
  update_config:
    parallelism: 4
  rollback_config:
    parallelism: 4
environment:
  TZ: Asia/Shanghai
image: nginx:alpine
networks:
  quick: null
restart: on-failure
volumes:
  - type: volume
    source: foo_data
    target: /data/

prepareLabels--------------------------------------------
prepareLabels depends_on:
  mysql:
    condition: service_started
deploy:
  replicas: 1
  update_config:
    parallelism: 4
  rollback_config:
    parallelism: 4
environment:
  TZ: Asia/Shanghai
image: nginx:alpine
labels:
  com.docker.compose.replace: 29a3657857037bccb9291c0fabe0f328e72940bc5a1864b14a2370bc57f37486
networks:
  quick: null
restart: on-failure
volumes:
  - type: volume
    source: foo_data
    target: /data/

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