帮助命令

docker version  #版本信息
docker info  #更加详细的系统信息
docker 命令 --help   #万能命令

文档地址:官方命令文档

镜像命令

docker images   #查看所有镜像

后面还可以接一些可选项

Name, shorthandDefaultDescription
--all , -a Show all images (default hides intermediate images)
--digests Show digests
--filter , -f Filter output based on conditions provided
--format Pretty-print images using a Go template
--no-trunc Don't truncate output
--quiet , -q Only show image IDs

例子:

PS C:\Users\13219> docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

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

例子2:

只查看镜像id

docker images -q

镜像搜索

除了在网页上搜索,我们还可以使用命令搜索

docker search mysql  #搜索MySQL

返回内容

NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   12113     [OK]
mariadb                           MariaDB Server is a high performing open sou…   4639      [OK]
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   905                  [OK]
phpmyadmin                        phpMyAdmin - A web interface for MySQL and M…   449       [OK]

筛选

更多的去看文档,这里举个例子

PS C:\Users\13219> docker search mysql --filter stars=3000  #筛选mysql镜像,stars要3000以上
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   12113     [OK]
mariadb   MariaDB Server is a high performing open sou…   4639      [OK]

镜像下载

docker pull mysql

这个有点像git拉取,只不过镜像的名字就是git地址罢了。

默认情况下拉取的是最新版的,我们可以指定tag。这个后面再说

PS C:\Users\13219> docker pull mysql
Using default tag: latest # 不指定tag默认就是latest 
latest: Pulling from library/mysql
72a69066d2fe: Pull complete  # 分层下载
93619dbc5b36: Pull complete
99da31dd6142: Pull complete
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
688ba7d5c01a: Pull complete
00e060b6d11d: Pull complete
1c04857f594f: Pull complete
4d7cfa90e6ea: Pull complete
e0431212d27d: Pull complete
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest # 真实地址

其中真实地址是最终使用的下载地址,他和docker pull mysql是等价的。

docker pull mysql
docker pull docker.io/library/mysql:latest

类似于一个是简写,一个是完整版

指定tag下载

下载5.7版本,注意这个tag一定要是镜像存在的tag。不清楚可以直接在网页上看,有对应的tag标签的。

docker pull mysql:5.7
PS C:\Users\13219> docker pull mysql:5.7
5.7: Pulling from library/mysql
72a69066d2fe: Already exists
93619dbc5b36: Already exists
99da31dd6142: Already exists
626033c43d70: Already exists
37d5d7efb64e: Already exists
ac563158d721: Already exists
d2ba16033dad: Already exists
0ceb82207cd7: Pull complete
37f2405cae96: Pull complete
e2482e017e53: Pull complete
70deed891d42: Pull complete
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

这里可以看到我们分层下载出现了Already exists;它表示已经存在,不用再下载了,这个就是分层下载的高明之处,镜像相同的部分可以复用的,不用重新下载,这个可以参考linux系统的联合文件系统

删除镜像

删除指定id或者名称的镜像

docker rmi -f 镜像id或者名称

删除所有镜像和多个镜像

# 删除全部
docker rmi -f $(docker images -aq)
# 删除多个
docker rmi -f 镜像id 镜像id 镜像id 镜像id

docker images -aq获取到所有镜像的id,通过$()传入,这样就能删除所有的镜像了

rmi

rm就是linux中删除文件的命令,i就是表示image镜像。

docker在删除的时候,如果分层中有其他的内容被其他镜像使用,那么删除镜像时只会删除没有使用的部分。

例子:

PS C:\Users\13219> docker rmi -f 3218b38490ce
Untagged: mysql:latest
Untagged: mysql@sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
Deleted: sha256:3218b38490cec8d31976a40b92e09d61377359eab878db49f025e5d464367f3b
Deleted: sha256:aa81ca46575069829fe1b3c654d9e8feb43b4373932159fe2cad1ac13524a2f5
Deleted: sha256:0558823b9fbe967ea6d7174999be3cc9250b3423036370dc1a6888168cbd224d
Deleted: sha256:a46013db1d31231a0e1bac7eeda5ad4786dea0b1773927b45f92ea352a6d7ff9
Deleted: sha256:af161a47bb22852e9e3caf39f1dcd590b64bb8fae54315f9c2e7dc35b025e4e3
Deleted: sha256:feff1495e6982a7e91edc59b96ea74fd80e03674d92c7ec8a502b417268822ff

容器的命令

先安装一个centos

docker pull centos

运行容器

如果命令不正确也有可能会产生一个错误的容器,但是我们可以进行删除。

run运行时一需要一个前台程序,否则大概率都是会运行失败了,会被视为没有需要的运行,自动结束
docker run [可选参数] image

# 参数说明
--name="Name"  容器的名字,用来区分容器
-d             后台运行的方式
-it            使用交互方式运行,进入容器查看内容
-p             指定容器端口 -P 8080:8080
    -P ip:主机端口:容器端口
    -P 主机端口:容器端口(常用)
    -P 容器端口
    容器端口,不写-P
-P              大写的P随机指定端口(将所有暴露的端口发布到随机端口)

测试一下

PS C:\Users\13219> docker run -it centos /bin/bash
[root@711a6da55831 /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

这里我们使用交互的方式运行centos,指定运行centos的bash

运行ls时可以查看到centos的文件列表

退出容器

上面-it进入到bash后,就是centos的操作了,我们可以使用exit退出

[root@711a6da55831 /]# exit
exit
PS C:\Users\13219> ls


    目录: C:\Users\13219


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2021/11/8     23:16                .config
d-----         2022/2/14     20:28                .docker
d-----        2021/11/13     15:52                .npm
d-----         2021/11/6      1:09                .Origin
d-----         2021/11/6      1:09                .QtWebEngineProcess
d-----         2022/2/13     20:49                .ssh
d-----         2021/11/6      0:02                .vscode
d-----         2021/11/6      0:30                ansel
d-r---         2021/11/5     21:55                Contacts
d-r---         2022/2/14     20:27                Desktop
d-r---        2021/12/30     13:17                Documents
d-r---         2022/2/14      2:23                Downloads
d-r---         2021/11/5     21:55                Favorites
d-----         2021/11/5     23:23                Intel
d-r---         2021/11/5     21:55                Links
d-r---         2021/11/5     21:55                Music
dar---         2022/2/14     20:28                OneDrive
d-r---         2021/11/5     21:56                Pictures
d-r---         2021/11/5     21:55                Saved Games
d-r---         2021/11/5     22:09                Searches
d-r---         2021/11/6      0:19                Videos
-a----         2022/2/14      0:23            854 .bash_history
-a----         2021/12/2     21:28            134 .gitconfig
-a----         2022/1/16     19:27             11 .node_repl_history
-a----         2021/11/7     21:38             43 .npmrc
-a----        2021/11/13     15:50             23 .rediscli_history
-a----         2021/12/2     21:27             60 .vuerc
-a----         2022/2/14      2:39            166 .yarnrc
-a----        2021/12/25      0:38           3381 id_rsa-remote-ssh
-a----        2021/12/25      0:38            743 id_rsa-remote-ssh.pub

查看运行中的容器

docker ps

结果啥都没有

PS C:\Users\13219> docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

因为我们刚刚exit退出交互式容器了,容器就被关闭了,我们可以增加-a的方式查看历史运行

PS C:\Users\13219> docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                     PORTS     NAMES
711a6da55831   centos    "/bin/bash"   4 minutes ago   Exited (0) 2 minutes ago             intelligent_dijkstra

可选参数

             # 空就是当前正在运行的容器
-a,-all      # 列出当前正在运行的容器+历史运行过的容器 
-q           # 显示容器的id
-aq          # 显示所有容器的id 
-n=?         # 显示最近几次创建的容器

退出容器

exit            # 停止容器并退出
ctrl + P + Q    # 退出但不停止容器

删除容器

docker rm 容器id                  # 删除单个容器,无法删除正在运行的容器,强制删除需要加上 -f
docker rm -f $(docker ps -aq)     # 删除所有容器
docker ps -a -q|xargs docker rm   # 管道符删除,linux方式,win用不了

例子1

删除一个没有运行的容器,比如已停止的容器,错误命令产生的容器

PS C:\Users\13219> docker rm 711a6da55831
711a6da55831
PS C:\Users\13219> docker ps -a
CONTAINER ID   IMAGE     COMMAND           CREATED         STATUS         PORTS     NAMES
efbc0c853466   centos    "/bin/bash"       4 minutes ago   Up 4 minutes             inspiring_dewdney
b4e5a93a15ac   centos    "-it /bin/bash"   5 minutes ago   Created                  inspiring_ardinghelli

例子2

删除一个正在运行的容器

PS C:\Users\13219> docker rm efbc0c853466
Error response from daemon: You cannot remove a running container efbc0c85346657617227e678fe339977ccc504e683b88ed82e6ecf4d63ed436e. Stop the container before attempting removal or force remove

删除就会报错,如果需要强制删除就得加上-f

PS C:\Users\13219> docker rm -f efbc0c853466
efbc0c853466

启动和停止容器

docker start 容器id        # 启动容器
docker restart 容器id      # 重启容器
docker stop 容器id         # 停止运行的容器
docker kill 容器id         # 强制停止容器

其他命令

后台运行容器

前面讲到了-d可以让容器后台运行,但是由于没有前台程序,我们往往会运行失败。

问题: 使用docker ps 查看,发现容器已经退出了!

_解释:_Docker容器后台运行,就必须有一个前台进程,容器运行的命令如果不是那些一直挂起的命令,就会自动退出。

比如,你运行了nginx服务,但是docker前台没有运行应用,这种情况下,容器启动后,会立即自杀,因为他觉得没有程序了,所以最好的情况是,将你的应用使用前台进程的方式运行启动。

所以一般我么可以配合-it一起使用,就不会马上就运行结束了。

docker run -dit centos /bin/bash

查看日志

PS C:\Users\13219> docker logs --help

Usage:  docker logs [OPTIONS] CONTAINER

Fetch the logs of a container

Options:
      --details        Show extra details provided to logs
  -f, --follow         Follow log output
      --since string   Show logs since timestamp (e.g.
                       2013-01-02T13:23:37Z) or relative (e.g. 42m for 42
                       minutes)
  -n, --tail string    Number of lines to show from the end of the logs
                       (default "all")
  -t, --timestamps     Show timestamps
      --until string   Show logs before a timestamp (e.g.
                       2013-01-02T13:23:37Z) or relative (e.g. 42m for 42
                       minutes)

可以看到logs有三个快捷参数:-n -f -t

t表示显示时间戳,n表示输出最近几条日志,后面需要接数字,f表示持续跟踪,如果有新的日志就会输出

例子:

docker logs -f bf08b7f2cd89

或者

# 命令
docker logs -f -t --tail 容器id

# 例子:我们启动 centos,并编写一段脚本来测试玩玩!最后查看日志
[root@kuangshen ~]# docker run -d centos /bin/sh -c "while true;do echo
kuangshen;sleep 1;done"
[root@kuangshen ~]# docker ps
CONTAINER ID IMAGE
c8530dbbe3b4 centos
# -t 显示时间戳
# -f 打印最新的日志
# --tail 数字 显示多少条!
[root@kuangshen ~]# docker logs -tf --tail 10 c8530dbbe3b4
2020-05-11T08:46:40.656901941Z kuangshen
2020-05-11T08:46:41.658765018Z kuangshen
2020-05-11T08:46:42.661015375Z kuangshen
2020-05-11T08:46:43.662865628Z kuangshen
2020-05-11T08:46:44.664571547Z kuangshen
2020-05-11T08:46:45.666718583Z kuangshen
2020-05-11T08:46:46.668556725Z kuangshen
2020-05-11T08:46:47.670424699Z kuangshen
2020-05-11T08:46:48.672324512Z kuangshen
2020-05-11T08:46:49.674092766Z kuangshen

默认情况下新的容器不一定有日志,所以可以手动增加然后查看

查看容器的进程

和linux的命令一样,使用top

docker top 容器id

例子:

PS C:\Users\13219> docker top 229417d3475a
UID      PID       PPID     C      STIME      TTY        TIME           CMD
root     2494      2469     0      14:48      ?          00:00:00       /bin/bash

查看镜像的元数据

很详细的镜像配置数据

docker inspect 镜像id

例子

PS C:\Users\13219> docker inspect 229417d3475a
[
    {
        "Id": "229417d3475aa3952e88871fedecee8ac373c7d7a41d1ab4793e28b83f3401b8", # 镜像id
        "Created": "2022-02-15T14:48:32.253028312Z", # 镜像创建时间
        "Path": "/bin/bash", # 镜像的bash控制台路径
        "Args": [],  # 启动镜像时使用的参数
        "State": {   # 镜像目前的状态
            "Status": "running",  # running启动
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 2494,  
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-02-15T14:48:32.442033643Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:5d0da3dc976460b72c77d94c8a1ad043720b0416bfc16c52c45d4847e53fadb6", # 从哪个镜像创建的,镜像的sha256
        "ResolvConfPath": "/var/lib/docker/containers/229417d3475aa3952e88871fedecee8ac373c7d7a41d1ab4793e28b83f3401b8/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/229417d3475aa3952e88871fedecee8ac373c7d7a41d1ab4793e28b83f3401b8/hostname",
        "HostsPath": "/var/lib/docker/containers/229417d3475aa3952e88871fedecee8ac373c7d7a41d1ab4793e28b83f3401b8/hosts",
        "LogPath": "/var/lib/docker/containers/229417d3475aa3952e88871fedecee8ac373c7d7a41d1ab4793e28b83f3401b8/229417d3475aa3952e88871fedecee8ac373c7d7a41d1ab4793e28b83f3401b8-json.log",
        "Name": "/musing_vaughan",
        "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,
            "CgroupnsMode": "private",
            "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": [
                24,
                120
            ],
            "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": null,
            "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/5fcbf2e451c4923a47de2b2cd7ab118aedd3c136cb8f282960fededd95e6fbca-init/diff:/var/lib/docker/overlay2/0abb528f410cc108d3b0720c276f012b7678fffdeda4c966daec793901555655/diff",
                "MergedDir": "/var/lib/docker/overlay2/5fcbf2e451c4923a47de2b2cd7ab118aedd3c136cb8f282960fededd95e6fbca/merged",
                "UpperDir": "/var/lib/docker/overlay2/5fcbf2e451c4923a47de2b2cd7ab118aedd3c136cb8f282960fededd95e6fbca/diff",
                "WorkDir": "/var/lib/docker/overlay2/5fcbf2e451c4923a47de2b2cd7ab118aedd3c136cb8f282960fededd95e6fbca/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],  # 挂载的配置数据
        "Config": {    # 镜像基本配置
            "Hostname": "229417d3475a",   # 镜像名字
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [   # 环境变量
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [  # cmd的命令
                "/bin/bash"
            ],
            "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": "d72bb7596168a6dd47f667ef5be2c455e2750c02c74ce2e0912eda71208071e9",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/d72bb7596168",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "f3f1626eb5c8890d7d6149404c033f08ea527a5a5ed1ec64d63aa3df12e9e5c6",
            "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": {  # bridge桥接模式
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "bdef423d6e958f6f1ee540f5c55fc607e94c557e0e2a726064aa27d9e647f2c9",
                    "EndpointID": "f3f1626eb5c8890d7d6149404c033f08ea527a5a5ed1ec64d63aa3df12e9e5c6",
                    "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路径

例子

PS C:\Users\13219> docker exec -it 229417d3475a /bin/bash
[root@229417d3475a /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

第二种方式

docker attach 容器id

attach与exec的区别就是,exec是新建的一个bash进程,而attach进入的是正在使用的bash进程,并且不需要-it

从容器里拷贝文件到主机上

从主机复制文件到容器,我们一般通过挂载,而容器的内容往外,我们通过cp命令

docker cp 容器id:容器内的文件路径 目标主机的路径

例子

在容器里创建一个文件,并复制到windows桌面上

PS C:\Users\13219> docker attach 229417d3475a      # 进入容器
[root@229417d3475a /]# cd /home                    # 进入容器的home目录
[root@229417d3475a home]# touch test.js            # 创建test.js文件
[root@229417d3475a home]# ls                       # 查看home目录下的文件列表
test.js
[root@229417d3475a home]# exit                     # 退出容器
exit
PS C:\Users\13219> docker cp 229417d3475a:/home/test.js C:\Users\13219\Desktop  # 复制到主机桌面上

命令小节(快速查询)

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 from the containers filesystem to the host path
#从容器中拷贝指定文件或者目录到宿主机中
create Create a new container # 创建一个新的容器,同
run,但不启动容器
diff Inspect changes on a container's filesystem # 查看 docker 容器变化
events Get real time events from the server # 从 docker 服务获取容
器实时事件
exec Run a command in an existing container # 在已存在的容器上运行命
令
export Stream the contents of a container as a tar archive # 导出容器的内
容流作为一个 tar 归档文件[对应 import ]
history Show the history of an image # 展示一个镜像形成历史
images List images # 列出系统当前镜像
import Create a new filesystem image from the contents of a tarball # 从
tar包中的内容创建一个新的文件系统映像[对应export]
info Display system-wide information # 显示系统相关信息
inspect Return low-level information on a container # 查看容器详细信息
kill Kill a running container # kill 指定 docker 容
器
load Load an image from a tar archive # 从一个 tar 包中加载一
个镜像[对应 save]
login Register or Login to the docker registry server # 注册或者登陆一个
docker 源服务器
logout Log out from a Docker registry server # 从当前 Docker
registry 退出
logs Fetch the logs of a container # 输出当前容器日志信息
port Lookup the public-facing port which is NAT-ed to PRIVATE_PORT #
查看映射端口对应的容器内部源端口
pause Pause all processes within a container # 暂停容器
ps List containers # 列出容器列表
pull Pull an image or a repository from the docker registry server #
从docker镜像源服务器拉取指定镜像或者库镜像
push Push an image or a repository to the docker registry server #
推送指定镜像或者库镜像至docker源服务器
restart Restart a running container # 重启运行的容器
rm Remove one or more containers # 移除一个或者多个容器
rmi Remove one or more images # 移除一个或多个镜像[无容器使用该
镜像才可删除,否则需删除相关容器才可继续或 -f 强制删除]
run Run a command in a new container # 创建一个新的容器并运行
一个命令
save Save an image to a tar archive # 保存一个镜像为一个
tar 包[对应 load]
search Search for an image on the Docker Hub # 在 docker hub 中搜
索镜像
start Start a stopped containers # 启动容器
stop Stop a running containers # 停止容器
tag Tag an image into a repository # 给源中镜像打标签
top Lookup the running processes of a container # 查看容器中运行的进程信
息
unpause Unpause a paused container # 取消暂停容器
version Show the docker version information # 查看 docker 版本号
wait Block until a container stops, then print its exit code # 截取容
器停止时的退出状态值
分类: Docker 标签: docker常用命令

评论

暂无评论数据

暂无评论数据

目录