大网数据广告活动
服务器运维问答

docker volume rm --force has no impact

· 52CE 我爱测

According to the official documentation it is possible to "force" remove a volume. The documentation remains quite unspecific what is meant by --force . To what I have found so far in the web this implicates the removal of volume…

问题原文

原帖链接 · Ranunculum · CC BY-SA 3.0

According to the official documentation it is possible to "force" remove a volume. The documentation remains quite unspecific what is meant by --force. To what I have found so far in the web this implicates the removal of volumes that are still in use by other containers.

Using the --force option appears to have no impact:

$ docker volume create mydata
$ docker docker run -v mydata:/mydata alpine:latest /bin/sh -c "touch /mydata/mydata.test; ls /mydata"
$ docker volume rm --force mydata
Error response from daemon: unable to remove volume: remove mydata: volume is in use - [1cbcfa3d47a32db7b0075e113216f7146a436a4da22a97dc2f7b60c68de95c3d]

This is the same output as when omitting the --force flag. Is this a bug or am I misunderstanding something?

$ docker version
Client:
 Version:       18.01.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    03596f5
 Built: Wed Jan 10 20:09:13 2018
 OS/Arch:       linux/amd64
 Experimental:  false
 Orchestrator:  swarm
Server:
 Engine:
  Version:      18.01.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   03596f5
  Built:        Wed Jan 10 20:07:43 2018
  OS/Arch:      linux/amd64
  Experimental: false

社区高分解答

原帖链接 · ElectRocnic · CC BY-SA 4.0

I am annoyed by all answers on all posts which do NOT provide a solution for the case which is mentioned by OP: The --force flag DOES NOT HELP.

Workaround (ATTENTION, you really should know what you do!):

docker volume ls # To list the volumes which currently exist

# To get the absolute path to the directory on your system where docker
# actually stores this volume
docker volume inspect --format '{{ .Mountpoint }}' <volume-name> 

# E.g. sudo rm -rf /var/lib/docker/volumes/database_volume (without the 
# _data directory)
sudo rm -rf <path-from-above> 

# Needed so docker will reload its volumes-directory to no longer list the
# deleted volume under docker volume ls and no longer make headaches on any
# build- or run-attempts.
sudo service docker restart 

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-01-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。