[LINUX] Docker command summary

Introduction

Docker is a technology that makes it easy to build an environment that has been introduced by many IT development companies. I will summarize the commands of Docker.

This Docker command

Details

docker login A command to log in to Docker. If you use Docker, do it first.

Terminal


% docker login
Username: =>Enter the user name registered in Docker
Password: =>Enter the password registered in Docker

=>If the user name and password match, log in.(Login Succeeded is displayed)

docker pull A command to download a Docker image from docker hub to a host.

Terminal


Example)hello-When downloading an image called world

% docker pull hello-world
=> hello-world is downloaded

=>If the user name and password match, log in.(Login Succeeded is displayed)

docker images A command to display a list of docker images in the host.

Terminal


Example)hello-After downloading the image called world

% docker images
=> REPOSITORY      TAG      IMAGE ID      CREATED      SIZE
   hello-world     latest   (Automatically created ID)  (When created)   (Data size)

docker run Command to create a container.

Terminal


Example)hello-After downloading the image called world

% docker run hello-world
=> hello-A container for world is created and executed.

% docker run -it ubuntu bash
=> ubuntu(OS name, docker image existing on docker hub)Container is created and a program called bash is executed.
(bash is the name of the shell. I'm running ubuntu's default command overwriting bash. By the way, ubuntu's default command is bash, so this time docker-Same for it run ubuntu.)

docker run --name A command to give a name and create a container.

Terminal



% docker run --name sample ubuntu
=>A container named sample is created from a docker image named ubuntu.

docker run --rm Command to delete the container immediately after starting the container.

Terminal



% docker run --rm hello-world
=> hello-After creating a container from a docker image called world and running it, the container is deleted immediately.
(Delete the container immediately because it leaves the container that is used only once.)

docker ps -a A command to display all containers.

Terminal


% docker ps -a
=>All containers are displayed.

% docker ps
=>Only running containers.

docker restart A command to restart a container that has been executed once.

Terminal



% docker restart (Container ID)or(Container name)
=>The container specified by the container ID is restarted.(STATUS becomes UP)

docker exec -it (container ID) or (container name) bash

A command that causes the restarted container to execute the program. (Replace the bash part with the program you want to run as appropriate)

Terminal



% docker exec -it (Container ID)or(Container name) bash
=>You can go inside the restarted container.(by bash)

docker commit (container ID) or (container name) (new image name)

A command to save the updated container as a new Docker image.

Terminal



% docker commit (Container ID)or(Container name) (New image name)
=>The docker image is saved and the ID is displayed.

docker tag (source) (target) A command to change the image name of docker image. Before pushing docker image to dockerhub, use it to make the repository name of the host image and the repository name of your own dockerhub to which you are pushing the same. (Dockerhub repository must be created on dockerhub)

Terminal



% docker tag (Host docker image repository name:Tag name) (docker username/Repository name)
=>The repository name of docker image will be the same as the repository name of dockerhub.(If the tag name is not specified, it will be latest.)

docker push A command to create a docker image in your repository.

Terminal



% docker push (image name)
=>The docker image is pushed to docker hub.(image name is docker username/Keep it the same as the repository name)

docker rmi Command to delete docker image. (The image name should be the same as the docker user name / repository name)

Terminal



% docker rmi (image name)or(image id)
=>The specified docker image is deleted

docker stop A command to stop a running container. (Set STATUS from UP to EXITED)

Terminal



% docker stop (Container name)or(Container ID)
=>The specified container is stopped.

docker rm A command to delete a container.

Terminal



% docker rm (Container name)or(Container ID)
=>The specified container is deleted

docker system prune A command to delete all stopped containers at once.

Terminal



% docker system prune
=>All stopped containers are deleted

reference

Udemy

Kameleon Lecturer "Docker course taught by US AI developers from scratch"

https://www.udemy.com/share/103aTRAEAdd1pTTHoC/

There is a charge, but it was very easy for me as a beginner to understand.

Finally

We hope that this post will help beginners review.

Recommended Posts

Docker command summary
Linux Command Summary
Django + Docker command
[Linux] Basic command summary
[Infrastructure] While command summary
Find, locate command summary
Image related command summary
Jupyter Docker image summary
Docker command super abbreviated version
[Learning memo] Django command summary
[Linux] User / group command summary
Jupyter Notebook Magic Command Personal Summary
Completion of docker command on Linux
Summary of "nl command Advent Calendar 2020"
Command list such as Docker / Kubernetes
Linux command # 4
samba summary
Linux command # 3
Command memorandum
Django Summary
python-pptx summary
Docker installation
command prompt
[Linux command summary] Command list [Must-see for beginners]
vim command
Linux Summary
Python summary
Django Summary
pyenv summary
String summary 1
sed command
Linux operation for beginners Basic command summary
grep command
Django + Docker
pytest summary
top command
matplotlib summary
Nginx setting summary (Flask + Docker + Gunicorn edition)
Command memorandum
mv command
seq command