Docker command cheat sheet

About this cheat sheet

It is not an exhaustive list, but a combination of commands and options used for basic purposes. If you want to know the meaning of each one, I think it will be easier to understand by referring to the following.

Reference -Understanding Docker -Docker command list

Docker Compose

Before starting the container

--Create and start a container according to the settings of docker-compose.yml

docker-compose up -d

--Created from Dockerfile

docker-compose up -d --build

--Container start / stop

docker-compose start
docker-compose stop

After starting the container

--Container list display

docker-compose ps

--Container deletion

docker-compose down


--Container confirmation (one-time command execution)

docker-compose run (Service name) (command)


Docker image manipulation

--Get image from Docker Hub

docker pull (Image name)

--Image list display

docker image ls

--Delete image

docker image rm (Image name)

--Create an image from Dockerfile

docker build -t (Image name) (Directory path where the Dockerfile is located)

Before starting the container

--Create a container from an image

docker create --name (Container name) (Image name)

--Launch the container from the image

docker run --rm -it -v (Local directory path):(Container directory path) -p (Local port):(Container port) (Image name) [(Startup process name)]

--Container start / stop

docker start (Container name)
docker stop (Container name)

After starting the container

--Container list display

docker ps -a

--Login to the container

docker exec -it (Container name) bash


--Container log check

docker logs -f (Container name)

--If the container doesn't work

docker run --rm (Container name) bash

--If you want to mount the directory from the middle --Stop the container once, take a snapshot image, add the -v option and start the container again

docker stop (Container name)
docker commit (Container name) (Image name)
docker run (option) (Image name)

Recommended Posts

Docker command cheat sheet
[Docker cheat sheet]
Docker command
javac, jar, java command cheat sheet
Java cheat sheet
JMeter cheat sheet
Docker command list
Docker command memo
docker basic command
Docker command summary
Docker command memorandum
Kotlin cheat sheet
[Docker] Command list
Mockito + PowerMock cheat sheet
Eclipse Collections cheat sheet
Rails Tutorial cheat sheet
Spring Boot2 cheat sheet
SCSS notation cheat sheet
docker error delete command
docker command personal summary
Oreshiki docker-compose cheat sheet
Java Stream API cheat sheet
[Eclipse] Shortcut key cheat sheet
Decomposing the Docker run command. .. ..
Docker Compact Manual (1: Basic / Basic Command)
C # cheat sheet for Java engineers
Competitive programming private cheat sheet (Java)
Getting Started with Doma-Criteria API Cheat Sheet
Easy installation of Docker with snap (1 command)
Grant docker command execution permission to ec2-user
Technology for reading source code (cheat sheet)
[Java] Data type / string class cheat sheet
Basic cheat sheet by language (Ruby, PHP)
Try to use docker command without sudo.