Catalogue
Docker Command Cheat Sheet

Docker Command Cheat Sheet

🌐 日本語で読む

Version

1
2
3
docker --version

Docker version 17.04.0-ce, build 4845c56

Containers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
docker ps                     # List running containers
docker ps -a # List all containers
docker start <CONTAINER ID> # Start a container
docker restart <CONTAINER ID> # Restart a container
docker stop <CONTAINER ID> # Stop a container
docker kill <CONTAINER ID> # Force-kill a container
docker attach <CONTAINER ID> # Attach to a container
docker top <CONTAINER ID> # Show container processes
docker logs -f <CONTAINER ID> # Show container logs
docker inspect <CONTAINER ID> # Show container details
docker rm <CONTAINER ID> # Remove a container by container ID
dockre rm <CONTAINER NAME...> # Remove containers by container name(s)
docker container prune # Remove stopped containers

dockr run -it -h <host name> <IMAGE>[:TAG] <command> # Start a container from an image and run a command

Images

1
2
3
4
docker pull <IMAGE NAME>[:tag]     # Download an image
docker images ls # List images
docker inspect <IMAGE ID> # Show image details
docker rmi <IMAGE ID> # Remove an image

Building Images

1
2
docker build -t NAME[:TAG]
docker commit -m "<comment here>" <CONTAINER ID> <IMAGE NAME>[:TAG]

Docker Compose

1
2
3
4
5
docker-compose up -d    # Start containers from images in detached mode
docker-compose ps # List containers
docker-compose stop # Stop all containers managed by docker compose
docker-compose start # Start all containers managed by docker compose
docker-compose rm # Remove all stopped containers managed by docker compose
Author

Kenzo Tanaka

Posted on

2017-04-14

Licensed under