Docker series 2 Docker related commands introduction

Docker commands

Doker service related commands

systemctl understanding

Linux service management two ways service and systemctl
systemd is the latest initialization system (init) of the Linux system. Its function is to increase the startup speed of the system, start as few processes as possible, and start as many processes concurrently as possible.
The process management command corresponding to systemd is systemctl

1. Start the docker service

systemctl start docker

2. Stop the docker service

systemctl start docker

3. Restart the docker service

systemctl restart docker

4. View docker service status

systemctl status docker

Insert picture description here

5. Start the docker service at boot

systemctl enable docker

Insert picture description here

Docker mirror related commands

1. View the mirror

View mirror: View all local mirrors

docker images
docker images -q //查看所用镜像的id

2. Search mirror

Search mirror: find the mirror you need from the network

docker search 镜像名称

Insert picture description here

3. Pull the image

Pull the image: download the image from the Docker warehouse to the local, the image name format is name: version number, if the version number is not specified, it is the latest version. If you don't know the mirror version, you can go to docker hub to search for the corresponding mirror.

docker pull 镜像名称

4. Delete the mirror

Delete local mirror

docker rmi 镜像id #删除本地指定镜像
docker rmi 'docker images -q' #删除本地所用的镜像

Docker container related commands

1 View the container

docker ps # 查看所有正在运行的容器
docker ps -a #查看所有容器

2. Create a container

Create and start the container

docker run 参数

Parameter Description:

** -i: ** Keep the container running. Usually used together with -t. After adding the two parameters of it, the container automatically enters the container after it is created, and after exiting the container, the container automatically closes.

**-t: ** Reallocate a pseudo input terminal for the container, usually used with -i.

**-d: ** Run the container in daemon (background) mode. To create a container to run in the background, you need to use docker exec to enter the container. After exiting, the container will not close.

** -it: **The container created is generally called an interactive container,

-id: The created container is generally called a guardian container

**–Name: **Name the container created

Example

**
Create a container and let it run in the background

Insert picture description here

3. Enter the container

docker exec 参数 #退出容器 容器不会关闭

Example

Enter the inside of the C3 container just created

Insert picture description here
Insert picture description here

4. Start the container

docker start 容器名称

5. Stop the container

If the container is running, the deletion fails, and the container needs to be stopped to delete

docker stop 容器名称

6. Delete the container

docker rm 容器名称

7. View container information

docker inspect 容器名称

Guess you like

Origin blog.csdn.net/pjh88/article/details/114731750