Description
In CI/CD workflows, changes to volumes may trigger interactive confirmation prompts, which can break automation and require manual intervention.
For example, when an existing volume does not match the Compose specification, Docker may prompt:
Volume "... " exists but doesn't match the Compose specification in the Compose file. Recreate (data will be lost)?
To support non-interactive environments, it would be useful to provide an option to automatically confirm volume recreation in such cases, while keeping the default interactive behavior unchanged.
This behavior is controlled via a per-volume label, allowing precise control when multiple volumes are defined in a single Compose file. The label does not apply globally.
Example
services:
app:
image: alpine
volumes:
- my_vol:/my_vol
- no_recreate_label:/no_recreate_label
volumes:
my_vol:
driver: local
driver_opts:
device: tmpfs
o: size=1k,uid=65530,gid=0,mode=0700,noexec
type: tmpfs
labels:
+ com.docker.compose.volume.recreate-when-spec-updated: "true"
foo: bar
nfs:
driver: local
driver_opts:
type: nfs
o: addr=XXX,nfsvers=4.2,soft,timeo=600,retrans=2,rsize=1048576,wsize=1048576
device: :/storage2/sonarr/media/
labels:
+ com.docker.compose.volume.recreate-when-spec-updated: "true"
no_recreate_label:
labels:
foo: bar
use case
- Shared tmpfs mounts between services
- Volume mounts that can be safely deleted without removing the underlying data (e.g., NFS volumes)
kimdre/doco-cd#1130 kimdre/doco-cd#1267
Description
In CI/CD workflows, changes to volumes may trigger interactive confirmation prompts, which can break automation and require manual intervention.
For example, when an existing volume does not match the Compose specification, Docker may prompt:
Volume "... " exists but doesn't match the Compose specification in the Compose file. Recreate (data will be lost)?To support non-interactive environments, it would be useful to provide an option to automatically confirm volume recreation in such cases, while keeping the default interactive behavior unchanged.
This behavior is controlled via a per-volume label, allowing precise control when multiple volumes are defined in a single Compose file. The label does not apply globally.
Example
services: app: image: alpine volumes: - my_vol:/my_vol - no_recreate_label:/no_recreate_label volumes: my_vol: driver: local driver_opts: device: tmpfs o: size=1k,uid=65530,gid=0,mode=0700,noexec type: tmpfs labels: + com.docker.compose.volume.recreate-when-spec-updated: "true" foo: bar nfs: driver: local driver_opts: type: nfs o: addr=XXX,nfsvers=4.2,soft,timeo=600,retrans=2,rsize=1048576,wsize=1048576 device: :/storage2/sonarr/media/ labels: + com.docker.compose.volume.recreate-when-spec-updated: "true" no_recreate_label: labels: foo: baruse case
kimdre/doco-cd#1130 kimdre/doco-cd#1267