Skip to content

Instantly share code, notes, and snippets.

@akkuman
Created April 27, 2023 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akkuman/6ed770535121f4fc2316d2ddccd3b60a to your computer and use it in GitHub Desktop.
Save akkuman/6ed770535121f4fc2316d2ddccd3b60a to your computer and use it in GitHub Desktop.
停止所有匹配规则的指定docker compose stack
compose_names=`docker compose ls | awk '(NR>1) && (/^[a-f0-9]{32}\s+/) {print($1)}'`
for name in ${compose_names[@]}; do
cids=`docker ps --filter "label=com.docker.compose.project=${name}" --format '{{.ID}}'`
for cid in ${cids[@]}; do
docker rm -f -v "$cid"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment