Skip to content

Attempting to Remove Volume Used by Service Does Not Report Error with CLI 23.0.1 #4082

@twinter-amosfivesix

Description

@twinter-amosfivesix

Description

When you attempt to remove a volume that's currently in use by a service, you should get an error stating that the volume is in use. With 23.0.1 you do not get an error.

The service usage is my primary scenario, but the same thing happens when using just a container without a service.

Inspecting the container does show it as using the volume.

I came across this in some tests I have for code that wraps the docker CLI. I'm testing that my code properly passes back the error from docker. So just a coincidence I'm trying this scenario really.

Reproduce

  1. docker volume create TestVolume
TestVolume
  1. docker service create --name TestService --mount type=volume,source=TestVolume,destination=/volume busybox:1.34.1 sleep infinity
yef18ac5rllrhib1wmpk86r22
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged
  1. docker volume rm TestVolume (this should produce an error)
TestVolume
  1. docker volume ls
DRIVER    VOLUME NAME
local     TestVolume

Expected behavior

When the same operation is done with the Docker CLI 20.10.22 you get this:

docker volume rm TestVolume

Error response from daemon: remove TestVolume: volume is in use - [85c3c0bea04f14ef8696a038ff1f5f08fd796dbff61276459c9c4336867a2072]

docker version

Client:
 Version:           23.0.1
 API version:       1.42
 Go version:        go1.19.5
 Git commit:        a5ee5b1
 Built:             Thu Feb  9 19:50:24 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.1
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.5
  Git commit:       bc3805a
  Built:            Thu Feb  9 19:46:47 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.18
  GitCommit:        2456e983eb9e37e47538f59ea18f2043c9a73640
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.1
    Path:     C:\Users\twinter\.docker\cli-plugins\docker-sbom.exe

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 20
 Server Version: 23.0.1
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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: active
  NodeID: 1bis6jp8bw0eg3x73wfrq1px5
  Is Manager: true
  ClusterID: exugqkpkx2cn5bp38wcw73dxo
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 10.2.96.83
  Manager Addresses:
   10.2.96.83:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2456e983eb9e37e47538f59ea18f2043c9a73640
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 4.18.0-425.3.1.el8.x86_64
 Operating System: Red Hat Enterprise Linux 8.7 (Ootpa)
 OSType: linux
 Architecture: x86_64
 CPUs: 3
 Total Memory: 5.741GiB
 Name: PRD-VIRT-RHL-56.AD.VERVEINDUSTRIAL.COM
 ID: IPGK:JLNH:EKXO:NZLH:O2O4:GQC5:PE7C:NYBC:BKQA:HNR2:Q36F:WCJ5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

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