Docker - 常用命令

Docker - 常用命令

帮助命令

docker version		 # 查看docker版本信息
docker info 		 # 显示docker的系统信息,包括镜像和容器的数量
docker 命令  --help   # 帮助命令

官网帮助文档:https://docs.docker.com/engine/reference/commandline/cli/

镜像命令

Docker Images 查看所有本地主机上镜像

[root@iZ2zeg7mctvft5renx1qvbZ docker]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    9c7a54a9a43c   6 months ago   13.3kB

# 解释
REPOSITORY		镜像的仓库源
TAG				镜像的标签
IMAGE ID		镜像的id
CREATED			镜像的创建时间
SIZE			镜像的大小

# 可选项
  -a, --all           # 列出所有镜像  
  -q, --quiet         # 只显示镜像的ID

Docker Search 搜索镜像

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker search mysql
NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                           MySQL is a widely used, open-source relation…   14591     [OK]       
mariadb                         MariaDB Server is a high performing open sou…   5564      [OK]       

# 可选项 --filter=stars=3000 搜索出来的镜像就是stars大于3000的
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker search mysql --filter=stars=3000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   14591     [OK]       
mariadb   MariaDB Server is a high performing open sou…   5564      [OK]

Docker Pull 拉取镜像

# 下载镜像 docker pull 镜像名:[tag]
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker pull mysql
Using default tag: latest																			#	如何不写tag,默认就是latest
latest: Pulling from library/mysql
8e0176adc18c: Pull complete 																		#	分层下载,docker images的核心 联合文件系统
2d2c52718f65: Pull complete 
d88d03ce139b: Pull complete 
4a7d7f11aa1e: Pull complete 
ce5949193e4c: Pull complete 
f7f024dfb329: Pull complete 
5fc3c840facc: Pull complete 
509068e49488: Pull complete 
cbc847bab598: Pull complete 
942bef62a146: Pull complete 
Digest: sha256:1773f3c7aa9522f0014d0ad2bbdaf597ea3b1643c64c8ccc2123c64afd8b82b1						#	签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest																		#	真实地址

# 等价
docker pull mysql
docker pull docker.io/library/mysql:latest

# 指定版本下载
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
9ad776bc3934: Pull complete 																		#	Already exists 已存在则不会下载
a280ac4a8665: Pull complete 
4047a3b08336: Pull complete 
435611dd4999: Pull complete 
f84f2572cb0b: Pull complete 
ef893e58839b: Pull complete 
42897f531783: Pull complete 
8a8aad27e96b: Pull complete 
6b2751f26202: Pull complete 
b0e9b86ed64c: Pull complete 
bfef93045c96: Pull complete 
Digest: sha256:880063e8acda81825f0b946eff47c45235840480da03e71a22113ebafe166a3d
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7


[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
mysql         latest    a3b6608898d6   2 weeks ago    596MB
mysql         5.7       547b3c3c15a9   2 weeks ago    501MB
hello-world   latest    9c7a54a9a43c   6 months ago   13.3kB

Docker rmi 删除镜像

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker rmi -f a3b6608898d6
Untagged: mysql:latest
Untagged: mysql@sha256:1773f3c7aa9522f0014d0ad2bbdaf597ea3b1643c64c8ccc2123c64afd8b82b1
Deleted: sha256:a3b6608898d600759effd58768b7213bb44a6d58ab3a53495dd88e6b2042a8a4
Deleted: sha256:a6316a7b5ef7408c536c06c5f20e6138cd8725c7ed3fc895ec2540d28f596d87
Deleted: sha256:ce9f13233387d62a08d318ab3756f8acca152ed67e54537ef94ceca1e899fdf4
Deleted: sha256:92ad3da2e834e507138e715ff516025fea7019725b49bf34ff62b97a2cfa8bfd
Deleted: sha256:1b03c6666623e2577b638c0f64223da6c323c0afd6f71dc5b7c5f337fb1c9a3a
Deleted: sha256:e09381dd9cb61b8167503ef95fbaed7170e65d18a9f35c0750b8919d76d0982f
Deleted: sha256:7537eb8f37e6a0dfada19f135ad86b82f995bfb10fdc2ac31bfffb5e911128be
Deleted: sha256:9af05b7bb2b5f7844eb2582d4211b77737a57b1f8087a728be40de0dc0eb542f
Deleted: sha256:d317a7939697b640434bdb25cb045b83b076cbb159baee7fbe198b1a72b8b6b4
Deleted: sha256:6437c74f97a878ba0770e4c41fdfb73df394605adf6cca9fbea813dd43f08c43
Deleted: sha256:d6fe63e8be63d078aeef9739f2c7ea101e6cc1a3f998d179af63a10e7f0f959d


[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker rmi -f 镜像id				   # 指定镜像ID进行删除
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker rmi -f 镜像id 镜像id 镜像id		# 指定多个镜像ID进行删除
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker rmi -f $(docker images -aq)	# 删除全部镜像

容器命令

说明:我们有了镜像才可以创建容器,linux,下载一个centos镜像来测试学习

docker pull centos

新建容器并启动

docker run [可选参数] image

# 参数说明
--name="Name"		容器名字 tomcat01
-d					后台方式运行
-it					使用交互方式运行,进入容器查看内容
-p					指定容器的端口 -p 8080:8080
		-p ip:主机端口:容器端口
		-p 主机端口:容器端口(常用)
		-p 容器端口
		容器端口
-P					随机指定端口

# 测试 启动并进入容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run --name docker-Centos  -it  centos /bin/bash
[root@da0d4127adcc /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

# 从容器中退回主机
[root@da0d4127adcc /]# exit
exit
[root@iZ2zeg7mctvft5renx1qvbZ ~]#

列出所有的运行中的容器

# 列出当前正在运行的容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

# 列出当前正在运行的容器 + 带出历史运行过的容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS                          PORTS     NAMES
da0d4127adcc   centos         "/bin/bash"   2 minutes ago    Exited (0) About a minute ago             docker-Centos
e0d090971357   9c7a54a9a43c   "/hello"      50 minutes ago   Exited (0) 50 minutes ago                 eager_feistel

# 列出最近运行的容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps -n=1
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                     PORTS     NAMES
da0d4127adcc   centos    "/bin/bash"   4 minutes ago   Exited (0) 2 minutes ago             docker-Centos

# 显示正在运行中的容器的编号
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps -q

# 显示所有的容器编号 
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps -aq
da0d4127adcc
e0d090971357

退出容器

# exit直接容器停止退出
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run  -it  centos /bin/bash
[root@cf967741518d /]# exit
exit
[root@iZ2zeg7mctvft5renx1qvbZ ~]# 

# Ctrl + P + Q
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run  -it  centos /bin/bash
[root@e24f34b01b24 /]# [root@iZ2zeg7mctvft5renx1qvbZ ~]# 

删除容器

docker rm 容器id					# 删除指定的容器,不能删除正在运行中的运行,如果要强制删除 rm -f
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker rm e0d090971357
e0d090971357

docker rm -f $(docker ps -aq)	 # 删除所有的容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker rm -f $(docker ps -aq)
cf967741518d
e24f34b01b24
da0d4127adcc		 

启动和停止容器的操作

docker start 容器id			# 启动容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker start 049b794f26cd
049b794f26cd

docker restart 容器id			# 重启容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker restart 049b794f26cd
049b794f26cd

docker stop 容器id			# 停止容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker stop 049b794f26cd
049b794f26cd

docker kill 容器id			# 杀掉容器
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker kill aed2454d35ee
aed2454d35ee

常用其他命令

后台启动容器

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run -d centos
fea5823954307616bf25217aa7f5c9ca2f164e2abc19de2f52d377f9ae5d43e7
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

# 问题docker ps 发现 centos 停止了

# 常见的坑,docker 容器使用后台运行,就必须要有一个前台进程,docker发现没有应用,就会自动停止
# nginx,容器启动后,发现自己没有提供服务,就会立即停止,就是没有程序了

查看日志

# 当前没有日志输出
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run -it centos /bin/bash
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS              PORTS     NAMES
244ee1bf970c   centos    "/bin/bash"   About a minute ago   Up About a minute             trusting_montalcini
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker logs -f -t --tail 10 244ee1bf970c

# 执行shell脚本
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker run -d centos /bin/sh -c "while true;do echo docker;sleep 1;done"
43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS        PORTS     NAMES
43351d4d5e18   centos    "/bin/sh -c 'while t…"   2 seconds ago   Up 1 second             sad_easley
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker logs -ft --tail 10  43351d4d5e18
2023-11-09T02:13:12.583149066Z docker
2023-11-09T02:13:13.584698453Z docker
2023-11-09T02:13:14.586420104Z docker
2023-11-09T02:13:15.588500238Z docker
2023-11-09T02:13:16.590157403Z docker

查看进程

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
43351d4d5e18   centos    "/bin/sh -c 'while t…"   3 minutes ago   Up 3 minutes             sad_easley
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker top 43351d4d5e18
UID                 PID                 PPID                C                   STIME               TTY                 TIME                
root                3514320             3514299             0                   10:12               ?                   00:00:00            
root                3525762             3514320             0                   10:15               ?                   00:00:00


# UID:用户ID		 PID:父ID			PPID:进程ID

查看容器的元数据

# 命令
docker inspect 容器ID

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker inspect 43351d4d5e18
[
    {
        "Id": "43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12",
        "Created": "2023-11-09T02:12:20.315824681Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "while true;do echo docker;sleep 1;done"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 3514320,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2023-11-09T02:12:20.499236889Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6",
        "ResolvConfPath": "/var/lib/docker/containers/43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12/hostname",
        "HostsPath": "/var/lib/docker/containers/43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12/hosts",
        "LogPath": "/var/lib/docker/containers/43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12/43351d4d5e1848e7ece0fa01e5ed0a03e18d35ef802b03c933d36cf6788b2c12-json.log",
        "Name": "/sad_easley",
        "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,
            "ConsoleSize": [
                12,
                138
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "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",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": [],
            "BlkioDeviceWriteBps": [],
            "BlkioDeviceReadIOps": [],
            "BlkioDeviceWriteIOps": [],
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "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",
                "/sys/devices/virtual/powercap"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/8ffcb8a686bf366efe708d70e352d76e2bb12ec48940cda8bc5d51a1c7cd2018-init/diff:/var/lib/docker/overlay2/d8cb8a8c63dd17ef5bebb4f028afe95a4cf5f38041b3fc432d9f9f4488d5eae7/diff",
                "MergedDir": "/var/lib/docker/overlay2/8ffcb8a686bf366efe708d70e352d76e2bb12ec48940cda8bc5d51a1c7cd2018/merged",
                "UpperDir": "/var/lib/docker/overlay2/8ffcb8a686bf366efe708d70e352d76e2bb12ec48940cda8bc5d51a1c7cd2018/diff",
                "WorkDir": "/var/lib/docker/overlay2/8ffcb8a686bf366efe708d70e352d76e2bb12ec48940cda8bc5d51a1c7cd2018/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "43351d4d5e18",
            "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 docker;sleep 1;done"
            ],
            "Image": "centos",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20210915",
                "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": "96508781cb10d493e5b2ecebf9c568a7c0f93d39110a675c1f48fabfbe81b280",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/96508781cb10",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "1abe64dac26ecf3d9194fdfd2523df221f7566adf6a979a482d9b2ff581772bc",
            "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": "1217050bd7f57996773b0df7710c41be633cde8401bc0e0c70e55a69376a4714",
                    "EndpointID": "1abe64dac26ecf3d9194fdfd2523df221f7566adf6a979a482d9b2ff581772bc",
                    "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 /bin/bash

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
43351d4d5e18   centos    "/bin/sh -c 'while t…"   11 minutes ago   Up 11 minutes             sad_easley
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker exec -it 43351d4d5e18 /bin/bash
[root@43351d4d5e18 /]# ps -ef
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 02:12 ?        00:00:00 /bin/sh -c while true;do echo docker;sleep 1;done
root         718       0  0 02:24 pts/0    00:00:00 /bin/bash
root         739       1  0 02:24 ?        00:00:00 /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 1
root         740     718  0 02:24 pts/0    00:00:00 ps -ef

# 命令
docker attach 容器id

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
43351d4d5e18   centos    "/bin/sh -c 'while t…"   17 minutes ago   Up 17 minutes             sad_easley
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker attach 43351d4d5e18
正在执行的当前的代码。。。

# docker exec 			# 进入容器后开启一个新的终端,可以在里面操作(常用)
# docker attach			# 进入容器正在执行的终端,不会启动新的进程!

从容器拷贝文件到主机上

# 命令
docker cp 容器id:/root/docker.java /home

[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
43351d4d5e18   centos    "/bin/sh -c 'while t…"   20 minutes ago   Up 19 minutes             sad_easley
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker exec -it 43351d4d5e18 /bin/bash
[root@43351d4d5e18 ~]# touch docker.java
[root@43351d4d5e18 ~]# ls
anaconda-ks.cfg  anaconda-post.log  docker.java  original-ks.cfg
[root@43351d4d5e18 ~]# exit
exit
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
43351d4d5e18   centos    "/bin/sh -c 'while t…"   23 minutes ago   Up 23 minutes             sad_easley
[root@iZ2zeg7mctvft5renx1qvbZ ~]# docker cp 43351d4d5e18:/root/docker.java /home
Successfully copied 1.54kB to /home
[root@iZ2zeg7mctvft5renx1qvbZ ~]# cd /home/
[root@iZ2zeg7mctvft5renx1qvbZ home]# ll
total 0
-rw-r--r-- 1 root root 0 Nov  9 10:35 docker.java
[root@iZ2zeg7mctvft5renx1qvbZ home]# 

# 拷贝是一个手动过程,之后我们使用 -v 卷的技术,可以实现,自动同步

总结

Docker - 常用命令_第1张图片

docker attach				Attach to a running container					# 当前 shell 下 attach 连接指定运行镜像
docker build				Build an image from a Dockerfile				# 从Dockerfile 定制镜像
docker commit				Create a new image from a container changes		# Manage builds
docker cp					Copy file/folders from the containers filesystem to the host path 	# 从容器中拷贝指定文件或者目录到宿主机
docker create				Create a new container							# 创建一个新容器,同run,但不启动容器
docker diff					Inspect chanages on a container`s filesystem	# 查看 docker 容器变化
docker events				Get real time events from the server 			# 从 docker 服务获取容器实时事件
docker exec					Run a command in an existing container 			# 在已存在的容器上运行命令
docker export				Stream the contents of a container as a tar archive		# 导出容器的内容流作为一个 tar 归档文件【对应 import】
docker history				show the history of an image 					# 展示一个镜像形成历史
docker images				List images										# 列出系统当前镜像
docker import				create a new filesystem image from the contents of a tarball 	# 从tar包中的内容创建一个新的文件系统映像【对应export】
docker info					Display system-wide information					# 显示系统相关信息
docker init (Beta)			Initialize a project with the files necessary to run the project in a container.
docker inspect				Return low-level information on a container 	# 查看容器详细信息
docker kill					kill a running container						# kill 指定docker 容器
docker load					load an image from a tar archive				# 从一个tar 包中加载一个镜像【对应save】
docker login				register or login to the docker registry server # 注册或者登陆一个docker 源服务器
docker logout				log out from a docker registry server			# 从当前 Docker registry 退出
docker logs					Fetch the logs of container						# 输出当前容器日志信息
docker pause				Pause all processes within a container 			# 暂停容器
docker port					Lookup the public-facing port which is NAT-ed to PRIVATE_PORT	# 查看映射端口对应的容器内部源端口
docker ps					list containers									# 列出容器列表
docker pull					pull an image or a repository from the docker registry server # 从docker镜像源服务器拉取指定镜像或者库镜像
docker push					push an image or a repository to the docker registry server # 推送指定镜像或者库镜像至docker源服务器
docker rename				The docker rename command renames a container.	# docker rename命令重命名容器。
docker restart				restart a running container						# 重启运行的容器
docker rm					remove one or more containers					# 移除一个或者多个容器
docker rmi					remove one or more images						# 移除一个或者多个镜像【无容器使用该镜像才可删除,否则需删除相关容器才可继续或者 -f 强制删除】
docker run					Run a command in a new container				# 创建一个新的容器并运行一个命令
docker save					Save an image to tar archive					# 保存一个镜像为一个tar包【对应load】				
docker search				Search for an image on the Docker Hub           # 在docker hub中搜索镜像
docker start				Start a stopped containers 						# 启动容器
docker stats				The docker stats command returns a live data stream for running containers
docker stop					stop a running containers 						# 停止容器
docker tag					Tag an image into a repository 					# 给源中镜像打标签
docker top					Lookup the running processes of a container		# 查看容器中运行的进程信息
docker unpause				unpause a paused container						# 取消暂停容器
docker update				The docker update command dynamically updates container configuration
docker version				show the docker version information 			# 查看docker版本号
docker wait					Block until a container stops, then print its exit code # 截取容器停止时的退出状态值 

你可能感兴趣的:(docker,容器,运维)