目次
稼働中のサービス一覧を確認
PS D:\> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f54a5de7d310 php:8.2-fpm "docker-php-entrypoi…" 8 hours ago Up 8 minutes 9000/tcp laravel-app
268a56615883 nginx:alpine "/docker-entrypoint.…" 15 hours ago Up 8 minutes 0.0.0.0:8080->80/tcp laravel-nginx
537430da4f98 postgres:latest "docker-entrypoint.s…" 15 hours ago Up 8 minutes 0.0.0.0:5432->5432/tcp laravel-postgres
PS D:\>
一括クリーンアップ
使用されていないイメージ、コンテナ、ネットワーク、ボリュームをまとめて削除する場合は以下を実行します。
docker system prune -a --volumes
オプション:
-a
: すべての未使用リソースを削除--volumes
: 未使用のボリュームも削除
コンテナ全停止
docker stop $(docker ps -q)
PS D:\> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f54a5de7d310 php:8.2-fpm "docker-php-entrypoi…" 8 hours ago Up 8 minutes 9000/tcp laravel-app
268a56615883 nginx:alpine "/docker-entrypoint.…" 15 hours ago Up 8 minutes 0.0.0.0:8080->80/tcp laravel-nginx
537430da4f98 postgres:latest "docker-entrypoint.s…" 15 hours ago Up 8 minutes 0.0.0.0:5432->5432/tcp laravel-postgres
PS D:\> docker stop $(docker ps -q)
f54a5de7d310
268a56615883
537430da4f98
PS D:\>
停止コンテナ全削除
docker rm $(docker ps -aq)
PS D:\> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f54a5de7d310 php:8.2-fpm "docker-php-entrypoi…" 8 hours ago Up 8 minutes 9000/tcp laravel-app
268a56615883 nginx:alpine "/docker-entrypoint.…" 15 hours ago Up 8 minutes 0.0.0.0:8080->80/tcp laravel-nginx
537430da4f98 postgres:latest "docker-entrypoint.s…" 15 hours ago Up 8 minutes 0.0.0.0:5432->5432/tcp laravel-postgres
PS D:\> docker stop $(docker ps -q)
f54a5de7d310
268a56615883
537430da4f98
PS D:\> docker rm $(docker ps -aq)
f54a5de7d310
268a56615883
537430da4f98
59695a014f6c
PS D:\>
dockerイメージ削除
現在のイメージ表示
docker images
PS D:\> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
php 8.2-fpm 78234d3aeebc 2 weeks ago 692MB
composer latest 706b731de8fe 3 weeks ago 286MB
nginx alpine 41523187cf7d 5 weeks ago 79.7MB
postgres latest 888402a8cd60 6 weeks ago 614MB
PS D:\>
イメージ削除
docker rmi <IMAGE_IDまたはREPOSITORY:TAG>
PS D:\> docker rmi composer
Untagged: composer:latest
Deleted: sha256:706b731de8fe83b64bb542bec1d6f20f95d300e21fbcc6f3f1b7fab39892e90e
PS D:\>
全イメージ削除
docker rmi $(docker images -q)
PS D:\> docker rmi $(docker images -q)
Untagged: php:8.2-fpm
Deleted: sha256:78234d3aeebce59eb9cb36e9f039e66ebbd5da47a796103c2a45d016596de10f
Untagged: nginx:alpine
Deleted: sha256:41523187cf7d7a2f2677a80609d9caa14388bf5c1fbca9c410ba3de602aaaab4
Untagged: postgres:latest
Deleted: sha256:888402a8cd6075c5dc83a31f58287f13306c318eaad016661ed12e076f3e6341
PS D:\> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
PS D:\>
未使用ボリューム削除
docker system prune --volumes
PS D:\> docker system prune --volumes
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all anonymous volumes not used by at least one container
- all dangling images
- unused build cache
Are you sure you want to continue? [y/N] y
Deleted Networks:
dockerbuild_laravel_network
Total reclaimed space: 0B
PS D:\>
未使用ボリューム【強制削除】
docker system prune --volumes -f
PS D:\> docker system prune --volumes -f
Total reclaimed space: 0B
PS D:\>