-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Description
Since docker compose version 2.32.1 (and presumably also 2.32.0), a container with an anonymous volume is re-created every time docker compose up is ran.
I believe the expected behaviour is to keep the container running if the configuration hasn't changed, like is the case with named volumes and bind mounts.
This issue is very similar to #12383, expect this is about anonymous volumes.
Without diving into the code, it seems likely this is a regression from #12363 which was partially fixed in #12386.
Steps To Reproduce
Anonymous volumes cause container to be re-created every time
With this docker-compose.yml:
services:
app:
image: busybox:1.37.0
init: true
command: ['tail', '-f', '/dev/null']
volumes:
- /my-anonymous-volumeRunning docker compose up --detach will re-create the container every time
Named volumes and bind mounts work correctly
While using a named volume or a bind mount will correctly keep the container running if nothing has changed:
services:
app:
image: busybox:1.37.0
init: true
command: ['tail', '-f', '/dev/null']
volumes:
- named-volume:/anonymous-volume
- ./bind-mount:/bind-mount
volumes:
named-volume:Running docker compose up --detach repeatedly will keep the container running
Compose Version
Docker Compose version v2.32.1
Docker Environment
Client: Docker Engine - Community
Version: 27.4.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.19.3
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.32.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 53
Running: 36
Paused: 0
Stopped: 17
Images: 222
Server Version: 27.4.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: local
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
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 88bf19b2105c8b17560993bee28a01ddc2f97182
runc version: v1.2.2-0-g7cb3632
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.8.0-51-generic
Operating System: Ubuntu 24.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 20
Total Memory: 30.98GiB
Name: scanb2023a393
ID: 71c5505a-7743-40a9-ab77-43569de8143b
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response