Docker常用命令

镜像

查看所有镜像

$ docker images
REPOSITORY                    TAG               IMAGE ID       CREATED        SIZE
dockerfiles-service_backend   latest            456219264829   42 hours ago   508MB
redis                         6.2               7afee305103f   2 weeks ago    127MB
dockerfiles-service_pg        latest            98506ca45f09   2 weeks ago    409MB
postgres                      14                5fb1753eb50a   2 weeks ago    409MB
node                          18                040c8b98d130   3 weeks ago    1.09GB
ubuntu                        20.04             6df894023726   4 weeks ago    72.8MB
python                        3.8-slim-buster   addd6962740a   2 months ago   118MB
redis                         6.0.6             1319b1eaa0b7   3 years ago    104MB

查看镜像元数据

$ docker inspect 7afee305103f
[
    {
        "Id": "sha256:7afee305103f505262f8c43e992e9ede17c2ea2b764f5ffb96ceb6a3a98e44fe",
        "RepoTags": [
            "redis:6.2"
        ],
        "RepoDigests": [
            "redis@sha256:b0c5ca6dd628b6e0166d6c50647dcbe5fbf27f4efa2af0538a99f83071ec4f48",
            "redis@sha256:fd12c0095e8bbe19350078745bb42d2a1a85c77b1e108b6e48807d9caebf0a13"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2023-08-16T15:27:25.516469967Z",
        "Container": "702c7c6fa017ccb7545cf89e93ecf48135e5b875154ebc145d37ab796dd17695",
        "ContainerConfig": {
            "Hostname": "702c7c6fa017",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "6379/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.16",
                "REDIS_VERSION=6.2.13",
                "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-6.2.13.tar.gz",
                "REDIS_DOWNLOAD_SHA=89ff27c80d420456a721ccfb3beb7cc628d883c53059803513749e13214a23d1"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"redis-server\"]"
            ],
            "Image": "sha256:25e79594d4c3c15c1cb398e257197265cd5799c9e52d3f5723197babd25708ba",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/data",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "20.10.23",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "6379/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.16",
                "REDIS_VERSION=6.2.13",
                "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-6.2.13.tar.gz",
                "REDIS_DOWNLOAD_SHA=89ff27c80d420456a721ccfb3beb7cc628d883c53059803513749e13214a23d1"
            ],
            "Cmd": [
                "redis-server"
            ],
            "Image": "sha256:25e79594d4c3c15c1cb398e257197265cd5799c9e52d3f5723197babd25708ba",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/data",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 127086149,
        "VirtualSize": 127086149,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/76ecf3a42496737257c4acf9528e97c36bdad5ad85ea6c3e27a36653f15188d9/diff:/var/lib/docker/overlay2/2259c2cdab38d8490f2a78360a38d784aa45cae931a2d02069a115916edfc39a/diff:/var/lib/docker/overlay2/750853958de01bf6d7c5c49bfa4db9634c106206a2d53e77e954595bcb8be4c8/diff:/var/lib/docker/overlay2/da079b3aeb48c6522bbe5879d2b63508ab85735a9e63379823040a66bd5c7a08/diff:/var/lib/docker/overlay2/b3248875a258988806b77c5860e4f031c57a6f6c0552029431dd981fb27697ae/diff",
                "MergedDir": "/var/lib/docker/overlay2/04b9d8ad708e30c281daa27a89615d2a6ecb84effa5e8c54436be1e06c2057e4/merged",
                "UpperDir": "/var/lib/docker/overlay2/04b9d8ad708e30c281daa27a89615d2a6ecb84effa5e8c54436be1e06c2057e4/diff",
                "WorkDir": "/var/lib/docker/overlay2/04b9d8ad708e30c281daa27a89615d2a6ecb84effa5e8c54436be1e06c2057e4/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:511780f88f80081112aea1bfdca6c800e1983e401b338e20b2c6e97f384e4299",
                "sha256:90413ed13ba691b94dcbedcdba9e9ebfc09e4e5348db7ecd323ae5a6fbe0d621",
                "sha256:c44e5d4e8bf9257bc01fbce9ff57bb8e93565e2cb94bffa46498f6f61ff86c02",
                "sha256:ece68d98008da0a3339b3a2962bd42ca3f656d76125de5386c7567c47190db34",
                "sha256:877a867aa6b626e94fc21b2c2137f2db04b9958fc85a85b4bd93d3201be1dea2",
                "sha256:7a98a9b90508d2e2ad54e80b001de8958f5a5ff005f5bbb93131971fef0db67f"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

删除镜像

docker rmi imageId

更新镜像

$ docker commit --help
Usage:	docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Create a new image from a container's changes
Options:
  -a, --author string    Author (e.g., "John Hannibal Smith
                         <hannibal@a-team.com>")
  -c, --change list      Apply Dockerfile instruction to the created image
  -m, --message string   Commit message
  -p, --pause            Pause container during commit (default true)

各个参数说明:

  • -m:设置提交的描述信息
  • -a:设置镜像作者信息
  • -p:更新时是否暂停容器,默认true
  • -c:修改 Dockerfile 指令,目前支持以下指令:CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | ONBUILD | USER | VOLUME | WORKDIR
  • CONTAINER:容器name或id
  • REPOSITORY[:TAG]: 指定要创建的目标镜像名,TAG默认latest

示例:

$ docker commit -m "update" -a "l" -p b16f4591e580 newImage:v2
$ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a newImage:v2

标记镜像

docker tag : 标记本地镜像,将其归入某一仓库。

语法

docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]

实例

$ docker images
REPOSITORY              TAG         IMAGE ID       CREATED        SIZE
mysql                   v20210809   0b77ba7dc7d0   17 hours ago   7.23GB
<none>                  <none>      7af0611bef07   2 years ago    4.41GB
$ # image_name
$ docker tag mysql:v20210809 mysql:v1
$ # image_id
$ docker tag 7af0611bef07 web:v1
$
$ docker images
REPOSITORY              TAG         IMAGE ID       CREATED        SIZE
mysql                   v1   0b77ba7dc7d0   17 hours ago   7.23GB
web                     v1          7af0611bef07   2 years ago    4.41GB

镜像导入和导出

$ # 查看镜像
$ docker images
$ # 导出镜像
$ # ps: 使用image_id导出的镜像导入后REPOSITORY、TAG为<none>
$ docker save image_name/image_id -o xxx.tar
$ # 加载镜像
$ docker load -i xxx.tar

镜像仓库

账号登录登出
docker login -u ***@163.com bpvast-docker.pkg.coding.net
docker logout bpvast-docker.pkg.coding.net
镜像拉取与上传

要先登陆到镜像仓库。

docker pull ubunut:18.04
docker push ubunut:18.04

容器

容器列表

$ docker ps -a
CONTAINER ID   IMAGE                         COMMAND                   CREATED         STATUS                        PORTS                                          
    NAMES
98463ec9fb28   dockerfiles-service_backend   "nginx -g 'daemon of…"   2 minutes ago   Up 2 minutes                  0.0.0.0:80->80/tcp, 80/udp, 0.0.0.0:443->443/tcp   service_backend
31784d1b76a8   redis:6.0.6                   "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes                  0.0.0.0:16379->6379/tcp                         
   service_redis
594c7a826e5c   dockerfiles-service_pg        "docker-entrypoint.s…"   2 minutes ago   Up About a minute (healthy)   0.0.0.0:15432->5432/tcp                         
   service_pg
  • -a: 查看所有容器

创建容器

docker run -it imageId /bin/bash

参数说明:

  • -a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三项;
  • -d: 后台运行容器,并返回容器ID;
  • -i: 以交互模式运行容器,通常与 -t 同时使用;
  • -P: 随机端口映射,容器内部端口随机映射到主机的端口
  • -p: 指定端口映射,格式为:主机(宿主)端口:容器端口
  • -t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
  • --name="containerName": 为容器指定一个名称;
  • --dns 8.8.8.8: 指定容器使用的DNS服务器,默认和宿主一致;
  • --dns-search example.com: 指定容器DNS搜索域名,默认和宿主一致;
  • -h "mars": 指定容器的hostname;
  • -e username="ritchie": 设置环境变量;
  • --env-file=[]: 从指定文件读入环境变量;
  • --cpuset="0-2" or --cpuset="0,1,2": 绑定容器到指定CPU运行;
  • -m:设置容器使用内存最大值;
  • --net="bridge": 指定容器的网络连接类型,支持 bridge/host/none/container: 四种类型;
  • --link=[]: 添加链接到另一个容器;
  • --expose=[]: 开放一个端口或一组端口;
  • --volume , -v: 绑定一个卷
  • --rm:退出时自动移除容器

进入容器

exec

推荐:退出容器终端,不会导致容器的停止。

docker exec -it containerId bash
attach
docker attach containerId

停止容器

docker stop containerId

查看容器元数据

$ # docker inspect containerId
$ docker inspect 31784d1b76
[
    {
        "Id": "31784d1b76a8e19545c250ed064bad6056d985ab58008309fd7b004e18299a0a",
        "Created": "2023-09-02T05:35:12.241089067Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "redis-server",
            "/usr/local/etc/redis/redis.conf"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 442,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2023-09-02T05:35:15.41170501Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:1319b1eaa0b7bcebae63af321fa67559b9517e8494060403d083bb3508fe52c8",
        "ResolvConfPath": "/var/lib/docker/containers/31784d1b76a8e19545c250ed064bad6056d985ab58008309fd7b004e18299a0a/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/31784d1b76a8e19545c250ed064bad6056d985ab58008309fd7b004e18299a0a/hostname",
        "HostsPath": "/var/lib/docker/containers/31784d1b76a8e19545c250ed064bad6056d985ab58008309fd7b004e18299a0a/hosts",
        "LogPath": "/var/lib/docker/containers/31784d1b76a8e19545c250ed064bad6056d985ab58008309fd7b004e18299a0a/31784d1b76a8e19545c250ed064bad6056d985ab58008309fd7b004e18299a0a-json.log",
        "Name": "/service_redis",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "D:\\workspace\\docker_code\\dockerfiles\\datas\\redis:/data/redis:rw",
                "D:\\workspace\\docker_code\\dockerfiles\\confs\\redis\\redis.conf:/usr/local/etc/redis/redis.conf:rw",
                "D:\\workspace\\docker_code\\dockerfiles\\logs\\redis:/logs/redis:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "dockerfiles_service_net",
            "PortBindings": {
                "6379/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "16379"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "ConsoleSize": [
                0,
                0
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": [],
            "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": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "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"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/df55b8ec306acc67f2ea68d85f223358d529e4b58061156ab04559200d09b6c0-init/diff:/var/lib/docker/overlay2/eb26efef692f3e53722d8f31a55e0dd661c3468fe0ee33e79771d71ea64a0821/diff:/var/lib/docker/overlay2/b9b7d604519ae63b7f93c6142c47173a61b6324f0d5d424cdd8d0069a31a9c35/diff:/var/lib/docker/overlay2/3ee9ef765b3ad5b5fa0cdd96a53d7a9a224594c69d6a3053710d0777fbaab694/diff:/var/lib/docker/overlay2/380f0d51cc7e1b7ca54a12ca4051982815f16980b57773dcdeedca2bf3e78c50/diff:/var/lib/docker/overlay2/e5ead22d0faac7f7600aa26ea4c71cc85ff7a2ba23c25ad0dba5d4466620a633/diff:/var/lib/docker/overlay2/013b912b127ad0578c9c77da7016441cf7ab62ed91b558da6b4a3808e020dc04/diff",
                "MergedDir": "/var/lib/docker/overlay2/df55b8ec306acc67f2ea68d85f223358d529e4b58061156ab04559200d09b6c0/merged",
                "UpperDir": "/var/lib/docker/overlay2/df55b8ec306acc67f2ea68d85f223358d529e4b58061156ab04559200d09b6c0/diff",
                "WorkDir": "/var/lib/docker/overlay2/df55b8ec306acc67f2ea68d85f223358d529e4b58061156ab04559200d09b6c0/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "D:\\workspace\\docker_code\\dockerfiles\\confs\\redis\\redis.conf",
                "Destination": "/usr/local/etc/redis/redis.conf",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "D:\\workspace\\docker_code\\dockerfiles\\logs\\redis",
                "Destination": "/logs/redis",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "9707786c881e826d4ead540bf60c22faa97bce65678b4b63aab7440e6afbc46a",
                "Source": "/var/lib/docker/volumes/9707786c881e826d4ead540bf60c22faa97bce65678b4b63aab7440e6afbc46a/_data",
                "Destination": "/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "bind",
                "Source": "D:\\workspace\\docker_code\\dockerfiles\\datas\\redis",
                "Destination": "/data/redis",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "31784d1b76a8",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "6379/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.12",
                "REDIS_VERSION=6.0.6",
                "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-6.0.6.tar.gz",
                "REDIS_DOWNLOAD_SHA=12ad49b163af5ef39466e8d2f7d212a58172116e5b441eebecb4e6ca22363d94"
            ],
            "Cmd": [
                "redis-server",
                "/usr/local/etc/redis/redis.conf"
            ],
            "Image": "redis:6.0.6",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/data",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "a3f091cda46aaeabee5ca908bd6b2157d1eb75bfc20694ca47c6c4c72b95ebd9",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.depends_on": "",
                "com.docker.compose.image": "sha256:1319b1eaa0b7bcebae63af321fa67559b9517e8494060403d083bb3508fe52c8",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "dockerfiles",
                "com.docker.compose.project.config_files": "D:\\workspace\\docker_code\\dockerfiles\\docker-compose.yml",
                "com.docker.compose.project.working_dir": "D:\\workspace\\docker_code\\dockerfiles",
                "com.docker.compose.service": "service_redis",
                "com.docker.compose.version": "2.18.1"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "23b60c3d97ab45dfcdfe88be042afcdddd5c54b44eaa74ec1c9bb4678064b0c4",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "6379/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "16379"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/23b60c3d97ab",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "dockerfiles_service_net": {
                    "IPAMConfig": {
                        "IPv4Address": "172.19.0.20"
                    },
                    "Links": null,
                    "Aliases": [
                        "service_redis",
                        "service_redis",
                        "31784d1b76a8"
                    ],
                    "NetworkID": "86406b786222115519b5e44eb8860a3ba863ac59398f5300f692e6d17075377f",
                    "EndpointID": "f87dc6c0a6b4fcbba9d2d13ad491c94638d49e046a874d6249ec490fc2e827dd",
                    "Gateway": "172.19.0.1",
                    "IPAddress": "172.19.0.20",
                    "IPPrefixLen": 24,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:13:00:14",
                    "DriverOpts": null
                }
            }
        }
    }
]

删除容器

docker rm containerId

参数:

  • -f:通过 SIGKILL 信号强制删除一个运行中的容器。
  • -l:移除容器间的网络连接,而非容器本身。
  • -v:删除与容器关联的卷。

容器导入和导出

# 导出容器
docker export container_id -o xxx.tar
# 导入容器
docker import xxx.tar containr:v1

所有命令

$ docker --help

Usage:	docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/Users/macminimd389/.docker")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/Users/macminimd389/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/Users/macminimd389/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/Users/macminimd389/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  config      Manage Docker configs
  container   Manage containers
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a 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
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  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
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
$

清理镜像

我们在使用 Docker 一段时间后,系统一般都会残存一些临时的、没有被使用的镜像文件,可以通过以下命令进行清理:

docker image prune
  • -a, --all: 删除所有没有用的镜像,而不仅仅是临时文件;
  • -f, --force:强制删除镜像文件,无需弹出提示确认;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值