该类命令主要用于docker容器的启动,停止,重启等。命令的详细如下:
# 检查docker的运行情况 docker在运行
[root@VM-4-16-centos ~]# ps -ef | grep docker
root 5144 19987 0 15:19 pts/0 00:00:00 grep --color=auto docker
root 6639 1 0 11:44 ? 00:00:01 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
# 1. 停止docker
[root@VM-4-16-centos ~]# systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
# 再次查看进程,docker进程没了
[root@VM-4-16-centos ~]# ps -ef | grep docker
root 6761 19987 0 15:20 pts/0 00:00:00 grep --color=auto docker
# 2. 查看docker状态
[root@VM-4-16-centos ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead) since 六 2022-05-14 15:20:45 CST; 1min 8s ago # 非活动状态
Docs: https://docs.docker.com
Process: 6639 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
Main PID: 6639 (code=exited, status=0/SUCCESS)
5月 14 11:44:29 VM-4-16-centos dockerd[6639]: time="2022-05-14T11:44:29.135480138+08:00" level=info msg="Docker daemon" commit=f756502 g...20.10.16
5月 14 11:44:29 VM-4-16-centos dockerd[6639]: time="2022-05-14T11:44:29.135545763+08:00" level=info msg="Daemon has completed initialization"
5月 14 11:44:29 VM-4-16-centos systemd[1]: Started Docker Application Container Engine.
5月 14 11:44:29 VM-4-16-centos dockerd[6639]: time="2022-05-14T11:44:29.153843277+08:00" level=info msg="API listen on /var/run/docker.sock"
5月 14 11:44:50 VM-4-16-centos dockerd[6639]: time="2022-05-14T11:44:50.371263981+08:00" level=info msg="ignoring event" container=4d6b5...kDelete"
5月 14 15:07:41 VM-4-16-centos dockerd[6639]: time="2022-05-14T15:07:41.877319415+08:00" level=info msg="ignoring event" container=162f4...kDelete"
5月 14 15:20:45 VM-4-16-centos systemd[1]: Stopping Docker Application Container Engine...
5月 14 15:20:45 VM-4-16-centos dockerd[6639]: time="2022-05-14T15:20:45.464195633+08:00" level=info msg="Processing signal 'terminated'"
5月 14 15:20:45 VM-4-16-centos dockerd[6639]: time="2022-05-14T15:20:45.465183057+08:00" level=info msg="Daemon shutdown complete"
5月 14 15:20:45 VM-4-16-centos systemd[1]: Stopped Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
# 3. 启动docker
[root@VM-4-16-centos ~]# systemctl start docker
# 查看docker状态
[root@VM-4-16-centos ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since 六 2022-05-14 15:23:15 CST; 26s ago # 运行状态
Docs: https://docs.docker.com
Main PID: 10058 (dockerd)
Tasks: 10
Memory: 34.2M
CGroup: /system.slice/docker.service
└─10058 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
5月 14 15:23:14 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:14.927072611+08:00" level=info msg="ccResolverWrapper: sending upda...le=grpc
5月 14 15:23:14 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:14.927088146+08:00" level=info msg="ClientConn switching balancer t...le=grpc
5月 14 15:23:14 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:14.943873236+08:00" level=info msg="[graphdriver] using prior stora...erlay2"
5月 14 15:23:14 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:14.948846903+08:00" level=info msg="Loading containers: start."
5月 14 15:23:15 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:15.060374423+08:00" level=info msg="Default bridge (docker0) is ass...ddress"
5月 14 15:23:15 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:15.099735043+08:00" level=info msg="Loading containers: done."
5月 14 15:23:15 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:15.124770820+08:00" level=info msg="Docker daemon" commit=f756502 g...0.10.16
5月 14 15:23:15 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:15.124828726+08:00" level=info msg="Daemon has completed initialization"
5月 14 15:23:15 VM-4-16-centos systemd[1]: Started Docker Application Container Engine.
5月 14 15:23:15 VM-4-16-centos dockerd[10058]: time="2022-05-14T15:23:15.139836110+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
# 4. 设置docker开机启动
[root@VM-4-16-centos ~]# systemctl enable docker
# 5. 查询所有命令的帮助命令
[root@VM-4-16-centos ~]# docker --help
# 6. 查询某个命令的帮助命令,以cp命令为例
[root@VM-4-16-centos ~]# docker cp --help
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Copy files/folders between a container and the local filesystem
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.
# cp命令可选参数
Options:
-a, --archive Archive mode (copy all uid/gid information)
-L, --follow-link Always follow symbol link in SRC_PATH
以上就是docker本身的一些帮助启动类的命令总结