Skip to content

Add optional auto-confirm label on volumes #13807

Description

@qianlongzt

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

  1. Shared tmpfs mounts between services
  2. Volume mounts that can be safely deleted without removing the underlying data (e.g., NFS volumes)

kimdre/doco-cd#1130 kimdre/doco-cd#1267

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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