[Docker] Command summary

__ ◆ Table of contents __ __1. Docker command

  1. Confirmation system ・ ・ ・ Confirmation of image and container
  2. Creation / activation system ・ ・ ・ Creation of image, activation of container
  3. 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!

Recommended Posts

Docker command summary
[Docker] Command summary
docker command personal summary
Docker command
Docker basic summary
Docker command list
Heroku command summary
Docker command memo
docker basic command
[Memo] docker summary
Docker command memorandum
[Docker] Command list
[Rails] Migration command summary
[Rails] rails db command summary
docker error delete command
Docker command cheat sheet
Decomposing the Docker run command. .. ..
Docker Compact Manual (1: Basic / Basic Command)
docker
docker memo
Easy installation of Docker with snap (1 command)
kubernetes + docker
spring × docker
Object-oriented summary
About Docker
Grant docker command execution permission to ec2-user
Command Pattern
Docker Intellij
Summary of Docker understanding by beginners ② ~ docker-compose ~
Docker installation
About Docker
Docker memorandum
Try to use docker command without sudo.
ransack summary
Understand Docker
Docker memorandum
Command docker-compose
[Docker] Introduction to docker compose Basic summary of docker-compose.yml
Environment construction command memo with Docker on AWS
Command to stop or delete all Docker resources
Summary of Docker understanding by beginners ① ~ docker run -p ~