[Docker] Command summary
__ ◆ Table of contents __
__1. Docker command
- Confirmation system ・ ・ ・ Confirmation of image and container
- Creation / activation system ・ ・ ・ Creation of image, activation of container
- Creation system: Create an image from the container __
__2. Docker Compose command __
1. Docker command
1) Confirmation system ・ ・ ・ Confirmation of image and container
| command |
Explanation |
| docker images |
You can see the list of images on the Host |
| docker images -f dangling=true |
Only dangling image can be displayed**An image that is |
| ------------------------------ |
------------------------------- |
| docker ps |
Show running containers |
| docker ps -a |
Show all containers with or without startup |
2) Creation / activation system ・ ・ ・ Creation of image, activation of container
__ * Caution *
docker run command = create + start (create and start container based on image) __
__ docker build command = Create image based on Dockerfile __
| command |
command |
| docker run <image> |
Create a container based on the image+Start-up |
| docker run -d <image> |
Detach after starting container(Run in the background) |
| docker run --rm |
Create a container based on the image, and automatically delete it when the container ends |
| docker run -v : |
Mount (synchronize) the file on the host and the file on the container?) |
| docker run -it -u $(id -u):$(id -g) -v : bash |
Mount by specifying the user ID**$ When using commands in copy and paste(Full-width)Please change to half-width |
| docker start <container> |
Start the stopped container |
| docker start -a <container> |
Start the container and execute the default command. You can see the execution contents.-a... attach |
| docker create <image> |
Create image from Dockerfile with container stopped |
| docker restart <container> |
Restart the running container**Stop + Start |
3) Creation system: Create an image from the container
| command |
command |
| docker commit <container> <name>:<tag> |
Create a new image from container |
| docker build -t <name> <directory> |
Create an image from a Docker file |
2. Docker Compose command
| $docker Compose command |
$docker command |
| docker-compose build |
docker build <build contexts> |
| docker-compose up |
docker run <image> |
| docker-compose ps |
docker ps |
| docker-compose exec <service> <command> |
docker exec <container> <command> |
| $docker Compose command |
Explanation |
| docker-compose up --build |
build and run |
| docker-compose down |
stop and rm(It also deletes all related images) |
We will update it from time to time!