我正在嘗試通過傳遞組態檔來stop
提供rm
服務,但這會停止所有服務,而不僅僅是具有此組態檔的服務。該up
命令似乎作業正常這是我的docker-compose.yaml
版本:'3.9'
services:
registry:
container_name: registry
image: registry:latest
pull_policy: missing
profiles:
- registry_service_profile
...
portainer:
container_name: portainer
image: localhost:5000/my-portainer
pull_policy: missing
profiles:
- other_services_profile
...
pihole:
container_name: pihole
image: localhost:5000/my-pihole
pull_policy: missing
profiles:
- other_services_profile
...
bitwarden:
container_name: bitwarden
image: localhost:5000/my-bitwarden
profiles:
- other_services_profile
pull_policy: missing
...
homeassistant:
container_name: homeassistant
image: localhost:5000/my-homeassistant
pull_policy: missing
profiles:
- other_services_profile
...
duplicati:
container_name: duplicati
image: localhost:5000/my-duplicati
pull_policy: missing
profiles:
- other_services_profile
...
使用兩個組態檔運行停止命令會停止所有服務,而不僅僅是具有提供的組態檔的服務
user@pc:/opt/docker$ sudo docker compose --profile registry_service_profile stop
[ ] Running 6/6
? Container pihole Stopped 4.6s
? Container portainer Stopped 0.7s
? Container registry Stopped 0.4s
? Container homeassistant Stopped 5.0s
? Container bitwarden Stopped 0.5s
? Container duplicati Stopped 4.5s
user@pc:/opt/docker$ sudo docker compose --profile registry_service_profile up --detach
[ ] Running 1/1
? Container registry Started 0.4s
user@pc:/opt/docker$ sudo docker compose --profile other_services_profile up --detach
[ ] Running 5/5
? Container portainer Started 0.7s
? Container homeassistant Started 0.2s
? Container bitwarden Started 0.6s
? Container pihole Started 0.9s
? Container duplicati Started 0.9s
user@pc:/opt/docker$ sudo docker compose --profile other_services_profile stop
[ ] Running 6/6
? Container portainer Stopped 0.4s
? Container pihole Stopped 4.5s
? Container registry Stopped 0.6s
? Container duplicati Stopped 4.4s
? Container homeassistant Stopped 5.0s
? Container bitwarden Stopped 0.5s
user@pc:/opt/docker$ docker --version
Docker version 20.10.17, build 100c701
難道我做錯了什么?
或者我應該只運行docker compose up
命令,這應該將服務更新到最新的拉取版本?
uj5u.com熱心網友回復:
看起來您只想停止包含組態檔的服務other_services_profile
而不是所有容器
我認為你不能,這仍然是 docker compose
https://github.com/docker/compose/issues/8139的問題
注意:我試圖重現它,對我來說,這種行為在使用時發生
docker compose --profile other_services_profile stop
但在使用時不會發生
docker compose --profile other_services_profile down
,在這種情況下,它會洗掉僅具有該組態檔的所有容器(您還將收到一條訊息,表明它也試圖洗掉默認網路,但不能作為只要有一個容器仍在運行,仍在使用它)
(我在 Windows 上使用 docker 20.10.17)
uj5u.com熱心網友回復:
這是一個實作選擇。組態檔僅在創建或啟動服務時起作用。看看這個執行緒
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/505081.html
下一篇:Docker運行入口點標志