前言
本文根据狂神说视频资料整理。https://www.bilibili.com/video/BV1og4y1q7M4?from=search&seid=16447684728895719563
Docker常用命令
帮助命令
docker version # 显示docker的版本
docker info # 显示docker的系统信息,包括镜像和容器的数量
docker 命令 --help # 帮助命令
帮助文档的地址:https://docs.docker.com/engine/reference/commandline/
镜像命令
docker images
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 5 months ago 13.3kB
#解释
REPOSITORY 镜像的仓库
TAG 镜像的标签
IMAGE ID 镜像的ID
CREATED 镜像的创建时间
SIZE 镜像的大小
#可选项
-a, --all #列出所有镜像
-q, --quiet #只显示镜像的id
docker search 搜索镜像
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 9645 [OK]
mariadb MariaDB is a community-developed fork of MyS… 3506 [OK]
#可选项
--filter=STARTS=3000
# 搜索镜像就是stars数大于3000
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker search mysql --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 9645 [OK]
mariadb MariaDB is a community-developed fork of MyS… 3506 [OK]
docker pull 下载镜像
#下载镜像 docker pull 镜像名[:tag]
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker pull mysql
Using default tag: latest #如果不写tag,默认就是 latest
latest: Pulling from library/mysql
8559a31e96f4: Pull complete #分层下载,docker image的核心 联合文件系统
d51ce1c2e575: Pull complete
c2344adc4858: Pull complete
fcf3ceff18fc: Pull complete
16da0c38dc5b: Pull complete
b905d1797e97: Pull complete
4b50d1c6b05c: Pull complete
c75914a65ca2: Pull complete
1ae8042bdd09: Pull complete
453ac13c00a3: Pull complete
9e680cd72f08: Pull complete
a6b5dc864b6c: Pull complete
Digest: sha256:8b7b328a7ff6de46ef96bcf83af048cb00a1c86282bfca0cb119c84568b4caf6 #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest # 真实地址
#等价于它
docker pull mysql
docker pull docker.io/library/mysql:latest
#指定版本下载
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker pull mysql:5.7
5.7: Pulling from library/mysql
8559a31e96f4: Already exists #有重复的文件就不会再下载了
d51ce1c2e575: Already exists
c2344adc4858: Already exists
fcf3ceff18fc: Already exists
16da0c38dc5b: Already exists
b905d1797e97: Already exists
4b50d1c6b05c: Already exists
d85174a87144: Pull complete
a4ad33703fa8: Pull complete
f7a5433ce20d: Pull complete
3dcd2a278b4a: Pull complete
Digest: sha256:32f9d9a069f7a735e28fd44ea944d53c61f990ba71460c5c183e610854ca4854
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
docker rmi 删除镜像
docker rmi -f 容器id #删除指定容器
docker rmi -f 容器id 容器id 容器id #删除多个指定容器
docker rmi -f $(docker images -aq) #递归删除所有的容器
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 9cfcce23593a 10 days ago 448MB
mysql latest be0dbf01a0f3 10 days ago 541MB
hello-world latest bf756fb1ae65 5 months ago 13.3kB
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker rmi -f 9cfcce23593a
Untagged: mysql:5.7
Untagged: mysql@sha256:32f9d9a069f7a735e28fd44ea944d53c61f990ba71460c5c183e610854ca4854
Deleted: sha256:9cfcce23593a93135ca6dbf3ed544d1db9324d4c40b5c0d56958165bfaa2d46a
Deleted: sha256:98de3e212919056def8c639045293658f6e6022794807d4b0126945ddc8324be
Deleted: sha256:17e8b88858e400f8c5e10e7cb3fbab9477f6d8aacba03b8167d34a91dbe4d8c1
Deleted: sha256:c04c087c2af9abd64ba32fe89d65e6d83da514758923de5da154541cc01a3a1e
Deleted: sha256:ab8bf065b402b99aec4f12c648535ef1b8dc954b4e1773bdffa10ae2027d3e00
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest be0dbf01a0f3 10 days ago 541MB
hello-world latest bf756fb1ae65 5 months ago 13.3kB
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:8b7b328a7ff6de46ef96bcf83af048cb00a1c86282bfca0cb119c84568b4caf6
Deleted: sha256:be0dbf01a0f3f46fc8c88b67696e74e7005c3e16d9071032fa0cd89773771576
Deleted: sha256:086d66e8d1cb0d52e9337eabb11fb9b95960e2e1628d90100c62ea5e8bf72306
Deleted: sha256:f37c61ee1973b18c285d0d5fcf02da4bcdb1f3920981499d2a20b2858500a110
Deleted: sha256:e40b8bca7dc63fc8d188a412328e56caf179022f5e5d5b323aae57d233fb1069
Deleted: sha256:339f6b96b27eb035cbedc510adad2560132925a835f0afddbcc1d311c961c14b
Deleted: sha256:d38b06cdb26a5c98857ddbc6ef531d3f57b00e325c0c314600b712efc7ff6ab0
Deleted: sha256:09687cd9cdf4c704fde969fdba370c2d848bc614689712bef1a31d0d581f2007
Deleted: sha256:b704a4a65bf536f82e5d8b86e633d19185e26313de8380162e778feb2852011a
Deleted: sha256:c37206160543786228aa0cce738e85343173851faa44bb4dc07dc9b7dc4ff1c1
Deleted: sha256:12912c9ec523f648130e663d9d4f0a47c1841a0064d4152bcf7b2a97f96326eb
Deleted: sha256:57d29ad88aa49f0f439592755722e70710501b366e2be6125c95accc43464844
Deleted: sha256:b17c024283d0302615c6f0c825137da9db607d49a83d2215a79733afbbaeb7c3
Deleted: sha256:13cb14c2acd34e45446a50af25cb05095a17624678dbafbcc9e26086547c1d74
Untagged: hello-world:latest
Untagged: hello-world@sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
容器命令
先下载linux镜像,centos
docker run [可选参数] image
#参数说明
--name="NAME" # 给容器起名字,作为区分
-d # 后台运行方式
-it # 使用交互方式运行,进入容器查看内容
-p # 指定容器的端口 -p 8080:8080
-p ip:主机端口:容器端口
-p 主机端口:容器端口 (常用)
-p # 随机指定端口
# 测试,启动并进入容器
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker run -it centos /bin/bash
[root@86b18b591598 /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@86b18b591598 /]# exit
exit
# 从容器中退回主机
[root@izbp1bbjc5qwrrd5z2ezayz /]# ls
bin boot dev etc home install.sh lib lib64 lost+found media mnt opt patch proc root run sbin srv sys tmp usr var www
列出所有运行的容器
#docker ps 命令
# 列出当前正在运行的容器
-a # 列出当前正在运行的容器以及历史运行过的容器
-n=? # 列出?个最近创建的容器
-q # 只显示容器的编号
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@izbp1bbjc5qwrrd5z2ezayz /]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86b18b591598 centos "/bin/bash" 10 minutes ago Exited (0) 8 minutes ago trusting_raman
58384b6b7d03 centos "/bin/bash/" 10 minutes ago Created festive_keller
3e1ad830adeb bf756fb1ae65 "/hello" 2 hours ago Exited (0) 2 hours ago peaceful_kepler
47c61563f7fc bf756fb1ae65 "/hello" 9 days ago Exited (0) 9 days ago fervent_turing
退出容器
exit # 直接容器退出并停止
Ctrl + p + q # 容器退出但不停止
删除容器
docker rm 容器id # 删除指定的容器,不能删除正在运行的容器,如果要强制删除 rm -f
docker rm -f $(docker iamges -aq) # 删除所有容器
docker ps -a|xargs docker rm # 删除所有容器
启动和停止容器的操作
docker start 容器id # 启动容器
docker restart 容器id # 重启容器
docker stop 容器id # 停止容器
docker kill 容器id # 杀死容器
常用其它命令
后台启动容器
# 命令 docker run -d centos
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker run -d centos
# 问题docker ps 发现centos停止了
# 常见问题:docker 容器使用后台运行,就必须要有一个前台进程,docker发现没有应用,就会自动停止。
# Nginx,容器启动后,发现自己没有提供服务,就会立刻停止,就是没有程序了
查看日志
docker logs -tf --tail 行数
# 自己编写一个脚本
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker run -d centos /bin/sh -c "while true;do echo daodao;sleep 1;done"
# 查看日志
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker logs -tf --tail 10 78ccaf77e9c8
2020-06-19T12:48:24.567002546Z daodao
2020-06-19T12:48:25.568855821Z daodao
2020-06-19T12:48:26.570856905Z daodao
2020-06-19T12:48:27.573024454Z daodao
2020-06-19T12:48:28.575491721Z daodao
查看容器中的id
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker top 78ccaf77e9c8
UID PID PPID C STIME TTY TIME CMD
root 9359 9342 0 20:47 ? 00:00:00 /bin/sh -c while true;do echo daodao;sleep 1;done
root 9692 9359 0 20:51 ? 00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1
查看镜像的元数据
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker inspect 78ccaf77e9c8
[
{
"Id": "78ccaf77e9c8c1f5220728fe5894915dbce1b0b4e1ea1562d850cea55d2629c5",
"Created": "2020-06-19T12:47:32.967578778Z",
"Path": "/bin/sh",
"Args": [
"-c",
"while true;do echo daodao;sleep 1;done"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 9359,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-06-19T12:47:33.458508266Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:831691599b88ad6cc2a4abbd0e89661a121aff14cfa289ad840fd3946f274f1f",
"ResolvConfPath": "/var/lib/docker/containers/78ccaf77e9c8c1f5220728fe5894915dbce1b0b4e1ea1562d850cea55d2629c5/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/78ccaf77e9c8c1f5220728fe5894915dbce1b0b4e1ea1562d850cea55d2629c5/hostname",
"HostsPath": "/var/lib/docker/containers/78ccaf77e9c8c1f5220728fe5894915dbce1b0b4e1ea1562d850cea55d2629c5/hosts",
"LogPath": "/var/lib/docker/containers/78ccaf77e9c8c1f5220728fe5894915dbce1b0b4e1ea1562d850cea55d2629c5/78ccaf77e9c8c1f5220728fe5894915dbce1b0b4e1ea1562d850cea55d2629c5-json.log",
"Name": "/stupefied_jones",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/38121800db8ce62235a7ab5a8d4f0ff5b58c8916b59c76ef2cab6ee04d52fc0b-init/diff:/var/lib/docker/overlay2/032acbb5a63c70ee37c8e02d18c7b316363361ab4f13ee86bfb14278c9cd180d/diff",
"MergedDir": "/var/lib/docker/overlay2/38121800db8ce62235a7ab5a8d4f0ff5b58c8916b59c76ef2cab6ee04d52fc0b/merged",
"UpperDir": "/var/lib/docker/overlay2/38121800db8ce62235a7ab5a8d4f0ff5b58c8916b59c76ef2cab6ee04d52fc0b/diff",
"WorkDir": "/var/lib/docker/overlay2/38121800db8ce62235a7ab5a8d4f0ff5b58c8916b59c76ef2cab6ee04d52fc0b/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "78ccaf77e9c8",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"while true;do echo daodao;sleep 1;done"
],
"Image": "centos",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"org.label-schema.build-date": "20200611",
"org.label-schema.license": "GPLv2",
"org.label-schema.name": "CentOS Base Image",
"org.label-schema.schema-version": "1.0",
"org.label-schema.vendor": "CentOS"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "373bbf0ff7fab5236a8423586ead6ec1be67535ecb06561e107d15002d88d2ef",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/373bbf0ff7fa",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "204bd4d0eb570751e120713ffd2eb90392710a4194bc92eda3e8f8220377f764",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "31ed304d052745b0a98f4d12f3b4215f3b3509bc2a1cad42764e05ad24b34435",
"EndpointID": "204bd4d0eb570751e120713ffd2eb90392710a4194bc92eda3e8f8220377f764",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
进入当前正在运行的容器
# 我们的容器通常都是后台的方式运行的,需要进入容器进行一些配置的修改
# 命令
docker exec -it 容器id bash
#测试
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
78ccaf77e9c8 centos "/bin/sh -c 'while t…" 12 minutes ago Up 12 minutes stupefied_jones
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker exec -it 78ccaf77e9c8 /bin/bash
[root@78ccaf77e9c8 /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@78ccaf77e9c8 /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 12:47 ? 00:00:00 /bin/sh -c while true;do echo daodao;sleep 1;done
root 779 0 0 13:00 pts/0 00:00:00 /bin/bash
root 805 1 0 13:00 ? 00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1
root 806 779 0 13:00 pts/0 00:00:00 ps -ef
# 方式二
docker attach 容器id
# 测试
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1489b57703f0 centos "/bin/bash" 31 seconds ago Up 30 seconds exciting_wescoff
[root@izbp1bbjc5qwrrd5z2ezayz ~]# docker attach 1489b57703f0
# docker exec # 进入容器后开启一个新的终端,可以在里面操作(常用)
# docker attach # 进入容器正在执行的终端,不会启动新的进程!
从容器拷贝文件到主机上
docker cp 容器id:容器内路径 目的地主机路径
# 进入到容器内部
[root@izbp1bbjc5qwrrd5z2ezayz home]# docker attach 6ddce6946291
[root@6ddce6946291 /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
[root@6ddce6946291 /]# cd home
[root@6ddce6946291 home]# ls
# 新建一个test.java文件
[root@6ddce6946291 home]# touch test.java
[root@6ddce6946291 home]# ls
test.java
# 退出
[root@6ddce6946291 home]# exit
exit
[root@izbp1bbjc5qwrrd5z2ezayz home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@izbp1bbjc5qwrrd5z2ezayz home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ddce6946291 centos "/bin/bash" 2 minutes ago Exited (0) 29 seconds ago elastic_nobel
1489b57703f0 centos "/bin/bash" 9 minutes ago Exited (0) 4 minutes ago exciting_wescoff
c0bc380485c7 centos "/bin/bash" 9 minutes ago Exited (127) 9 minutes ago agitated_wilson
6bc800b8b1c7 centos "/bin/bash" 10 minutes ago Exited (0) 10 minutes ago wonderful_varahamihira
05c890820c86 centos "/bin/bash" 41 minutes ago Exited (0) 41 minutes ago gracious_lalande
4abe9a45eb5f centos "/bin/bash" 4 hours ago Exited (127) 4 hours ago dazzling_noyce
58384b6b7d03 centos "/bin/bash/" 4 hours ago Created festive_keller
3e1ad830adeb bf756fb1ae65 "/hello" 6 hours ago Exited (0) 6 hours ago peaceful_kepler
47c61563f7fc bf756fb1ae65 "/hello" 9 days ago Exited (0) 9 days ago fervent_turing
# 复制到主机中
[root@izbp1bbjc5qwrrd5z2ezayz home]# docker cp 6ddce6946291:/home/test.java /home
[root@izbp1bbjc5qwrrd5z2ezayz home]# ls
f2 test1 test.java www
小结
attach Attach to a running container # 当前shell下attach连接指定运行的镜像
build Build an image from a Dockerfile # 通过Dockerfile定制镜像
commit Create a new image from a container changes #提交当前容器为新的镜像
cp Copy files/folders between a container and the local filesystem #从容器中拷贝指定文件或目录到宿主机中
create Create a new container # 创建一个新的容器,同run,但不启动容器
diff Inspect changes to files or directories on a container's filesystem #查看docker容器的变化
events Get real time events from the server # 从docker服务获取容器实时事件
exec Run a command in a running container # 在已存在的容器上运行命令
export Export a container filesystem as a tar archive # 导出容器的内容流作为一个tar归档文件[对应import]
history Show the history of an image # 展示一个镜像形成历史
images List images # 列出系统当前的镜像
import Import the contents from a tarball to create a filesystem image # 从tar包中的内容创建一个新的文件系统镜像[对应export]
info Display system-wide information # 显示系统相关信息
inspect Return low-level information on Docker objects # 查看容器详细信息
kill Kill one or more running containers # 杀死指定的docker容器
load Load an image from a tar archive or STDIN # 从一个tar包加载一个镜像[对应save]
login Log in to a Docker registry # 注册或者登录一个docker源服务器
logout Log out from a Docker registry # 从当前Docker registry退出
logs Fetch the logs of a container # 输出当前容器日志信息
pause Pause all processes within one or more containers # 暂停容器
port List port mappings or a specific mapping for the container # 查看映射端口对应容器内部源端口
ps List containers # 列出容器列表
pull Pull an image or a repository from a registry # 从docker镜像源服务器拉取指定镜像或库镜像
push Push an image or a repository to a registry # 推送指定镜像或者库镜像至docker源服务器
rename Rename a container # 给docker容器重新命名
restart Restart one or more containers # 重启运行的容器
rm Remove one or more containers # 移除一个或者多个容器
rmi Remove one or more images # 移除一个或者多个镜像[无容器使用该镜像时才可删除,否则需删除相关容器才可继续或 -f 强制删除]
run Run a command in a new container # 创建一个新的容器并运行一个命令
save Save one or more images to a tar archive (streamed to STDOUT by default) # 保存一个镜像为一个tar包[对应load]
search Search the Docker Hub for images # 在docker hub中搜索镜像
start Start one or more stopped containers # 启动容器
stats Display a live stream of container(s) resource usage statistics # 实时显示容器资源使用统计
stop Stop one or more running containers # 停止容器
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE # 给源中镜像打标签
top Display the running processes of a container # 查看容器中运行的进程信息
unpause Unpause all processes within one or more containers # 取消暂停容器
update Update configuration of one or more containers # 更新一个或多个容器配置
version Show the Docker version information # 查看docker版本号
wait Block until one or more containers stop, then print their exit codes # 截取容器停止时的退出状态值
可视化
- portainer
docker run -d -p 9000:9000 \
> --restart=always \
> -v /var/run/docker.sock:/var/run/docker.sock \ --name prtainer-test \docker.io/portainer/portainer
网站:http://112.124.16.77:8088
设置用户和密码登入进去即可