[英]docker-compose down not removing anonymous volumes
I have my docker-compose as below:我的 docker-compose 如下:
version: '3.8'
services:
mongodb:
image: 'mongo'
restart: 'always'
volumes:
- data:/data/db
backend:
build: ./api
ports:
- '5000:5000'
volumes:
- upload:/app/upload
depends_on:
- mongodb
frontend:
build: ./client
ports:
- '3000:3000'
volumes:
- ./client:/app
- /app/node_modules
stdin_open: true
tty: true
depends_on:
- backend
volumes:
data:
upload:
After running docker-compose up -d
it creates 4 volumes:运行
docker-compose up -d
后,它会创建 4 个卷:
DRIVER VOLUME NAME
local 86ade5422b5ec2ab35fc3b2ea76099596d8b4a36f96c4428fbab4559ae5cff74
local de8c5f9680c5c4f73b6a3d4a1b3d4d2f962cc498d34a49dbfbbbda4cc7652288
local easyhome_data
local easyhome_upload
The 2 anonymous volumes seem to target to the /data/configdb
and /app/node_modules
2 个匿名卷似乎针对
/data/configdb
和/app/node_modules
If I shut it down then run it again docker-compose down && docker-compose up -d
it will create 2 more anonymous volumes identical to the previous two如果我关闭它然后再次运行它
docker-compose down && docker-compose up -d
它将再创建 2 个与前两个相同的匿名卷
DRIVER VOLUME NAME
local 5a1ead27ac78cee770aad636c156818c246377132b50a8b773b35be46146195f
local 86ade5422b5ec2ab35fc3b2ea76099596d8b4a36f96c4428fbab4559ae5cff74
local bc3063ff80f63f9e7ed5c1e319ee43a6d92ccdb2bfa9aec7e6be35378a566638
local de8c5f9680c5c4f73b6a3d4a1b3d4d2f962cc498d34a49dbfbbbda4cc7652288
local easyhome_data
local easyhome_upload
I dont want to run docker-compose down -v
because it will remove my 2 named volumes as well.我不想运行
docker-compose down -v
因为它也会删除我的 2 个命名卷。 Please provide guidance!请提供指导!
You need to explicitly ask docker-compose to remove volumes:您需要明确要求 docker-compose 删除卷:
docker-compose down -v
Reason is: volumes are meant to persist data useful to the user.原因是:卷旨在保存对用户有用的数据。
Read more about available options:阅读有关可用选项的更多信息:
docker-compose down --help
Output: Output:
Usage: docker compose down
Stop and remove containers, networks
Options:
--remove-orphans Remove containers for services not defined in the Compose file.
--rmi string Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")
-t, --timeout int Specify a shutdown timeout in seconds (default 10)
-v, --volumes volumes Remove named volumes declared in the volumes section of the Compose file and anonymous volumes
attached to containers.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.