Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yangjinheng opened this issue Mar 14, 2023 · 6 comments

Comments

@yangjinheng
Copy link

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/
@lwmacct
Copy link

lwmacct commented Mar 17, 2023

Seek a solution

@tuxthepenguin84
Copy link

tuxthepenguin84 commented Mar 18, 2023

This bug is breaking some automation with my setup so I rolled back to 2.15.1-1 and it seems to be working fine now.

See what versions are available to install (assuming you are using the plugin):
apt list docker-compose-plugin -a

Then you can install a previous version, in my case 2.15.1-1 doesn't have this bug:
apt install -y --allow-downgrades docker-compose-plugin=2.15.1-1~ubuntu.20.04~focal

I was then able to run docker-compose up -d and it didn't continually restart/recreate my containers

If you want to tell apt to hold at that version and not upgrade, run: sudo apt-mark hold docker-compose-plugin
Once this bug is fixed you can remove the hold and it will upgrade: sudo apt-mark unhold docker-compose-plugin

@ShaneMcC
Copy link

This may be a duplicate of #10307, fixed by #10275

@yangjinheng
Copy link
Author

Seek a solution

looks like someone has already submitted a PR, just wait

@yangjinheng
Copy link
Author

This bug is breaking some automation with my setup so I rolled back to 2.15.1-1 and it seems to be working fine now.

See what versions are available to install (assuming you are using the plugin): apt list docker-compose-plugin -a

Then you can install a previous version, in my case 2.15.1-1 doesn't have this bug: apt install -y --allow-downgrades docker-compose-plugin=2.15.1-1~ubuntu.20.04~focal

I was then able to run docker-compose up -d and it didn't continually restart/recreate my containers

If you want to tell apt to hold at that version and not upgrade, run: sudo apt-mark hold docker-compose-plugin Once this bug is fixed you can remove the hold and it will upgrade: sudo apt-mark unhold docker-compose-plugin

nice advice, I didn't know that before

@yangjinheng
Copy link
Author

这可能是#10307的副本,由#10275修复

It has been fixed in the latest v2 after my test

@yangjinheng yangjinheng closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants