Docker常用命令应用(v19.03.15)

记录:365

场景:在CentOS 7.9操作系统上,应用Docker常用命令以及Docker命令原版明细。

版本:

操作系统:CentOS 7.9

Docker版本:Docker 19.03.15

1.Docker常用操作

1.1下载镜像

下载格式:docker pull 镜像名称:镜像版本

下载命令:docker pull redis:6.2.8

解析:使用docker pull下载,从容器镜像仓库下载下载。

1.2查看镜像列表

命令实例:docker images

解析:查看本地全部镜像列表。

命令格式:docker images REPOSITORY

命令实例:docker images redis

解析:查看本地REPOSITORY相同的全部镜像列表。

1.3搜索镜像

命令格式:docker search 镜像名称

命令实例:docker search httpd

解析:从Docker Hub中搜索镜像。

1.4创建容器

使用已经下载到本地的镜像,创建容器。

(1)docker create创建

创建容器:docker create --name redis-27013 -p 27013:6379 redis:6.2.8

解析:使用docker create创建容器,创建完成后不会立运行容器,需使用命令启动。

(2)docker run创建并营销

创建容器:docker run -dit --name redis-27012 -p 27012:6379 redis:6.2.8

解析:使用docker run创建容器,创建完成后会立即运行容器。

1.5查看容器列表

命令:docker ps -a

解析:找出容器CONTAINER ID,例如:8073e0bd334c。

1.6启动容器

启动格式:docker start 容器ID

启动命令:docker start 8073e0bd334c

解析:启动容器,一个已经创建的容器,端口映射关系已经创建完成。

1.7停止容器

停止格式:docker stop 容器ID

停止命令:docker stop 8073e0bd334c

解析:停止容器会返回容器ID。

1.8重启容器

重启格式:docker restart 容器ID

重启实例:docker restart 8073e0bd334c

解析:重启容器会返回容器ID。

1.9进入容器

命令格式:docker exec 容器ID 命令

命令实例:docker exec -it 8073e0bd334c /bin/bash

命令实例:docker exec -it 8073e0bd334c bash

命令实例:docker exec -it redis-27012 bash

解析:执行docker exec命令时,使用容器ID和容器名称都可以进入容器内部。

退出容器:exit

1.10查看容器基础信息

命令格式:docker inspect 容器ID

命令实例:docker inspect b28cd322912a

解析:以JSON格式返回容器的基础信息,比如容器的ID、状态、镜像等常见配置信息;比如容器与宿主机之间的网络、端口、文件目录、驱动等信息。

1.11更新容器配置

命令格式:docker update [OPTIONS] CONTAINER [CONTAINER...]

命令实例:docker update --cpus 1  b28cd322912a

解析:限制cpu数量为1。

1.12 kill容器

命令格式:docker kill 容器ID

命令实例:docker kill b28cd322912a

解析:kill容器会返回容器ID。

1.13删除容器

命令格式:docker rm 容器ID

命令实例:docker rm 8073e0bd334c

解析:删除容器会返回容器ID。

1.15删除镜像

命令格式:docker rmi 镜像ID

命令实例:docker rmi 83a5aeccc5e0

解析:删除容器会返回镜像ID,一个有容器正在运行的镜像不能删除。

1.16查看容器日志

命令格式:docker logs [OPTIONS] 容器ID

命令实例:docker logs -f 8073e0bd334c

解析:-f,对于正在运行的容器,会持续输出日志。

1.17容器和本地文件系统之间拷贝数据

(1)本地拷贝到容器内部

命令格式:docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

命令实例:docker cp /home/apps/workInLocal/hz.txt 8073e0bd334c:/home/workInDocker

(2)容器内部拷贝到本地

命令格式:docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH

命令实例:docker cp 8073e0bd334c:/home/workInDocker/hz.txt  /home/hz01.txt

1.18查看容器内部文件系统文件和目录变化

命令格式:docker diff [OPTIONS] 容器ID

命令实例:docker diff 3645454c4d2f

解析:看到容器内部的文件和目录变化,如果有的话。

1.19导出容器的文件系统

命令格式:docker export [OPTIONS] 容器ID

命令实例:docker export -o localFile 3645454c4d2f

解析:把容器内部文件系统导出到本地的一个文件。

1.20根据容器创建镜像

(1)创建镜像

命令格式:docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

命令实例:docker commit 3645454c4d2f myredis:6.2.8.1

解析:根据一个已经在运行的容器,创建一个新的镜像。

(2)查看镜像

命令:docker images myredis

解析:可以看到镜像已经生成。

(3)应用镜像

创建容器:docker run -dit --name redis-27014 -p 27014:6379 myredis:6.2.8.1

解析:使用新创建的镜像myredis:6.2.8.1,创建容器

1.21查看镜像历史信息

命令格式:docker history [OPTIONS] IMAGE

命令实例:docker history -H httpd:2.4.54

解析:可以查看镜像包历史变更信息。

1.22查看docker信息

命令实例:docker info

解析:显示docker在系统侧的信息。包括docker管理的容器、镜像、驱动、插件、以及系统信息。

1.23暂停容器

命令格式:docker pause 容器ID

命令实例:docker pause 94a43200c09e

解析:执行后容器状态为:Paused。

1.24查看容器与宿主机之间映射端口

命令格式:docker port 容器ID

命令实例:docker port 94a43200c09e

解析:查看容器和本地之间端口映射。

1.25重命名容器名称

命令格式:docker rename 容器ID 新名称

命令实例:docker rename 94a43200c09e myredis-27014

解析:把容器名称重新命名为myredis-27014。

1.26把镜像保存为文件

命令格式:docker save [OPTIONS] IMAGE

命令实例:docker save -o myimg 22f0fd7102c4

解析:把镜像22f0fd7102c4保存到一个文件中。

1.27查看容器的实时统计信息

命令实例:docker stats

解析:查看一个容器统计信息,包括CPU、内存、网络IO、块IO、PID等信息的实时统计。

命令格式:docker stats [OPTIONS] 容器ID

命令实例:docker stats 3645454c4d2f

解析:查看全部容器统计信息,包括CPU、内存、网络IO、块IO、PID等信息的实时统计。

1.28镜像修改版本号

命令格式:docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

命令实例:docker tag myredis:6.2.8.1 myredis:6.2.8.2

解析:镜像修改为版本号,只是tag变了,镜像ID、SIZE等其它字段不变。

1.29查看容器的进程信息

命令格式:docker top CONTAINER [ps OPTIONS]

命令实例:docker top 94a43200c09e

解析:查看容器的进程信息,包括UID、PID、CMD等。

1.30取消暂停

命令格式:docker unpause 容器ID

命令实例:docker unpause 94a43200c09e

解析:取消暂停,把容器的Paused状态变更为Up状态。

1.31查看docker版本

命令实例:docker version

解析:查看docker版本详细信息,包括引擎、容器、客户端等版本细节。

命令实例:docker --version

解析:只显示客户端版本信息。

1.32等待容器停止

命令格式:docker wait 容器ID

命令实例:docker wait 94a43200c09e

解析:容器停止时,能接收到返回值:0。

1.33登录Docker registry

本例登录本地搭建的harbor镜像仓库。

命令实例:docker login http://192.168.19.166:18021 -u admin -p Harbor12345

解析:http://192.168.19.166:18021是harbor服务器地址;-u是用户名;-p,指定密码。

1.34登出Docker registry

命令实例:docker logout

解析:默认是登出:Removing login credentials for https://index.docker.io/v1/

命令实例:docker logout http://192.168.19.166:18021

解析:登出搭建的私有仓库。

1.35下载镜像(Harbor镜像仓库)

命令实例:docker pull 192.168.19.166:18021/library/redis-photon:v2.3.5

解析:192.168.19.166:18021,本地搭建的harbor镜像仓库;/library/redis-photon:v2.3.5是镜像仓库的实际镜像。

1.36上传镜像(Harbor镜像仓库)

(1)修改docker配置信息

修改命令:vi /etc/docker/daemon.json

修改内容:

{
 "registry-mirrors":["http://192.168.19.166:18021"],
 "insecure-registries":["192.168.19.166:18021"]
}

加载配置和重启docker:systemctl daemon-reload && systemctl restart docker

(2)先把本地镜像打标签

命令:docker tag redis:7.0.7 192.168.19.166:18021/library/redis:7.0.7

解析:先把镜像打标签

(3)命令行登录Docker registry(Harbor)

命令实例:docker login http://192.168.19.166:18021 -u admin -p Harbor12345

解析:http://192.168.19.166:18021是harbor服务器地址;-u是用户名;-p,指定密码。

(4)推送

命令实例:docker push 192.168.19.166:18021/library/redis:7.0.7

解析:默认对推送到docker.io/library/redis;指定推送。

(5)命令行登出Docker registry(Harbor)

命令实例:docker logout http://192.168.19.166:18021

解析:登出Docker registry(Harbor),否则一直有效。

2.Docker命令明细

类一:管理命令

2.1帮助命令docker --help

使用帮助命令docker --help,可以查看docker支持的全部命令。

命令明细[参数明细]:

Usage:	docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
  -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 "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.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
  context     Manage contexts
  engine      Manage the docker engine
  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.

2.2帮助命令docker builder --help

命令明细[参数明细]:

Usage:	docker builder COMMAND

Manage builds

Commands:
  build       Build an image from a Dockerfile
  prune       Remove build cache

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

2.3帮助命令docker config --help

命令明细[参数明细]:

Usage:	docker config COMMAND

Manage Docker configs

Commands:
  create      Create a config from a file or STDIN
  inspect     Display detailed information on one or more configs
  ls          List configs
  rm          Remove one or more configs

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

2.4帮助命令docker container

命令明细[参数明细]:

Usage:	docker container COMMAND

Manage containers

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  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
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  inspect     Display detailed information on one or more containers
  kill        Kill one or more running containers
  logs        Fetch the logs of a container
  ls          List containers
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  prune       Remove all stopped containers
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  run         Run a command in a new container
  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
  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
  wait        Block until one or more containers stop, then print their exit codes

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

2.5帮助命令docker context --help

命令明细[参数明细]:

Usage:	docker context COMMAND

Manage contexts

Commands:
  create      Create a context
  export      Export a context to a tar or kubeconfig file
  import      Import a context from a tar or zip file
  inspect     Display detailed information on one or more contexts
  ls          List contexts
  rm          Remove one or more contexts
  update      Update a context
  use         Set the current docker context

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

2.6帮助命令docker engine --help

命令明细[参数明细]:

Usage:	docker engine COMMAND

Manage the docker engine

Commands:
  activate    Activate Enterprise Edition
  check       Check for available engine updates
  update      Update a local engine

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

2.7帮助命令docker image --help

命令明细[参数明细]:

Usage:	docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

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

2.8帮助命令docker network --help

命令明细[参数明细]:

Usage:	docker network COMMAND

Manage networks

Commands:
  connect     Connect a container to a network
  create      Create a network
  disconnect  Disconnect a container from a network
  inspect     Display detailed information on one or more networks
  ls          List networks
  prune       Remove all unused networks
  rm          Remove one or more networks

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

2.9帮助命令docker node --help  

命令明细[参数明细]:

Usage:	docker node COMMAND

Manage Swarm nodes

Commands:
  demote      Demote one or more nodes from manager in the swarm
  inspect     Display detailed information on one or more nodes
  ls          List nodes in the swarm
  promote     Promote one or more nodes to manager in the swarm
  ps          List tasks running on one or more nodes, defaults to current node
  rm          Remove one or more nodes from the swarm
  update      Update a node

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

2.10帮助命令docker plugin --help

命令明细[参数明细]:

Usage:	docker plugin COMMAND

Manage plugins

Commands:
  create      Create a plugin from a rootfs and configuration. Plugin data directory must contain config.json and rootfs directory.
  disable     Disable a plugin
  enable      Enable a plugin
  inspect     Display detailed information on one or more plugins
  install     Install a plugin
  ls          List plugins
  push        Push a plugin to a registry
  rm          Remove one or more plugins
  set         Change settings for a plugin
  upgrade     Upgrade an existing plugin

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

2.11帮助命令docker secret --help

命令明细[参数明细]:

Usage:	docker secret COMMAND

Manage Docker secrets

Commands:
  create      Create a secret from a file or STDIN as content
  inspect     Display detailed information on one or more secrets
  ls          List secrets
  rm          Remove one or more secrets

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

2.12帮助命令docker service --help

命令明细[参数明细]:

Usage:	docker service COMMAND

Manage services

Commands:
  create      Create a new service
  inspect     Display detailed information on one or more services
  logs        Fetch the logs of a service or task
  ls          List services
  ps          List the tasks of one or more services
  rm          Remove one or more services
  rollback    Revert changes to a service's configuration
  scale       Scale one or multiple replicated services
  update      Update a service

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

2.13帮助命令docker stack --help

命令明细[参数明细]:

Usage:	docker stack [OPTIONS] COMMAND

Manage Docker stacks

Options:
      --orchestrator string   Orchestrator to use (swarm|kubernetes|all)

Commands:
  deploy      Deploy a new stack or update an existing stack
  ls          List stacks
  ps          List the tasks in the stack
  rm          Remove one or more stacks
  services    List the services in the stack

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

2.14帮助命令docker swarm --help

命令明细[参数明细]:

Usage:	docker swarm COMMAND

Manage Swarm

Commands:
  ca          Display and rotate the root CA
  init        Initialize a swarm
  join        Join a swarm as a node and/or manager
  join-token  Manage join tokens
  leave       Leave the swarm
  unlock      Unlock swarm
  unlock-key  Manage the unlock key
  update      Update the swarm

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

2.15帮助命令docker system --help

命令明细[参数明细]:

Usage:	docker system COMMAND

Manage Docker

Commands:
  df          Show docker disk usage
  events      Get real time events from the server
  info        Display system-wide information
  prune       Remove unused data

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

2.16帮助命令docker trust --help  

命令明细[参数明细]:

Usage:	docker trust COMMAND

Manage trust on Docker images

Management Commands:
  key         Manage keys for signing Docker images
  signer      Manage entities who can sign Docker images

Commands:
  inspect     Return low-level information about keys and signatures
  revoke      Remove trust for an image
  sign        Sign an image

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

2.17帮助命令docker volume --help

命令明细[参数明细]:

Usage:	docker volume COMMAND

Manage volumes

Commands:
  create      Create a volume
  inspect     Display detailed information on one or more volumes
  ls          List volumes
  prune       Remove all unused local volumes
  rm          Remove one or more volumes

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

类二:普通命令

2.18帮助命令docker attach --help

命令明细[参数明细]:

Usage:	docker attach [OPTIONS] CONTAINER

Attach local standard input, output, and error streams to a running container

Options:
      --detach-keys string   Override the key sequence for detaching a container
      --no-stdin             Do not attach STDIN
      --sig-proxy            Proxy all received signals to the process (default true)

2.19帮助命令docker build --help

命令明细[参数明细]:

Usage:	docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile

Options:
      --add-host list           Add a custom host-to-IP mapping (host:ip)
      --build-arg list          Set build-time variables
      --cache-from strings      Images to consider as cache sources
      --cgroup-parent string    Optional parent cgroup for the container
      --compress                Compress the build context using gzip
      --cpu-period int          Limit the CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int           Limit the CPU CFS (Completely Fair Scheduler) quota
  -c, --cpu-shares int          CPU shares (relative weight)
      --cpuset-cpus string      CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string      MEMs in which to allow execution (0-3, 0,1)
      --disable-content-trust   Skip image verification (default true)
  -f, --file string             Name of the Dockerfile (Default is 'PATH/Dockerfile')
      --force-rm                Always remove intermediate containers
      --iidfile string          Write the image ID to the file
      --isolation string        Container isolation technology
      --label list              Set metadata for an image
  -m, --memory bytes            Memory limit
      --memory-swap bytes       Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --network string          Set the networking mode for the RUN instructions during build (default "default")
      --no-cache                Do not use cache when building the image
  -o, --output stringArray      Output destination (format: type=local,dest=path)
      --platform string         Set platform if server is multi-platform capable
      --progress string         Set type of progress output (auto, plain, tty). Use plain to show container output (default "auto")
      --pull                    Always attempt to pull a newer version of the image
  -q, --quiet                   Suppress the build output and print image ID on success
      --rm                      Remove intermediate containers after a successful build (default true)
      --secret stringArray      Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret
      --security-opt strings    Security options
      --shm-size bytes          Size of /dev/shm
      --squash                  Squash newly built layers into a single new layer
      --ssh stringArray         SSH agent socket or keys to expose to the build (only if BuildKit enabled) (format: default|<id>[=<socket>|<key>[,<key>]])
      --stream                  Stream attaches to server to negotiate build context
  -t, --tag list                Name and optionally a tag in the 'name:tag' format
      --target string           Set the target build stage to build.
      --ulimit ulimit           Ulimit options (default [])

2.20帮助命令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)

2.21帮助命令docker cp --help --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.

Options:
  -a, --archive       Archive mode (copy all uid/gid information)
  -L, --follow-link   Always follow symbol link in SRC_PATH

2.22帮助命令docker create --help

命令明细[参数明细]:

Usage:	docker create [OPTIONS] IMAGE [COMMAND] [ARG...]

Create a new container

Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup for the container
      --cidfile string                 Write the container ID to the file
      --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period in microseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  -c, --cpu-shares int                 CPU shares (relative weight)
      --cpus decimal                   Number of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
      --device-write-iops list         Limit write rate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --domainname string              Container NIS domain name
      --entrypoint string              Overwrite the default ENTRYPOINT of the image
  -e, --env list                       Set environment variables
      --env-file list                  Read in a file of environment variables
      --expose list                    Expose a port or a range of ports
      --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
      --group-add list                 Add additional groups to join
      --health-cmd string              Command to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries int             Consecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname string                Container host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even if not attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc string                     IPC mode to use
      --isolation string               Container isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited file of labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver for the container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mount to the container
      --name string                    Assign a name to the container
      --network network                Connect a container to a network
      --network-alias list             Add network-scoped alias for the container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid string                     PID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 for unlimited)
      --platform string                Set platform if server is multi-platform capable
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rm                             Automatically remove the container when it exits
      --runtime string                 Runtime to use for this container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (in seconds) to stop a container
      --storage-opt list               Storage driver options for the container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use
  -v, --volume list                    Bind mount a volume
      --volume-driver string           Optional volume driver for the container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir string                 Working directory inside the container

2.23帮助命令docker diff --help

命令明细[参数明细]:

Usage:	docker diff CONTAINER

Inspect changes to files or directories on a container's filesystem

2.24帮助命令docker events --help

命令明细[参数明细]:

Usage:	docker events [OPTIONS]

Get real time events from the server

Options:
  -f, --filter filter   Filter output based on conditions provided
      --format string   Format the output using the given Go template
      --since string    Show all events created since timestamp
      --until string    Stream events until this timestamp

2.25帮助命令docker exec --help

命令明细[参数明细]:

Usage:	docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container

Options:
  -d, --detach               Detached mode: run command in the background
      --detach-keys string   Override the key sequence for detaching a container
  -e, --env list             Set environment variables
  -i, --interactive          Keep STDIN open even if not attached
      --privileged           Give extended privileges to the command
  -t, --tty                  Allocate a pseudo-TTY
  -u, --user string          Username or UID (format: <name|uid>[:<group|gid>])
  -w, --workdir string       Working directory inside the container

2.26帮助命令docker export --help

命令明细[参数明细]:

Usage:	docker export [OPTIONS] CONTAINER

Export a container's filesystem as a tar archive

Options:
  -o, --output string   Write to a file, instead of STDOUT

2.27帮助命令docker history --help

命令明细[参数明细]:

Usage:	docker history [OPTIONS] IMAGE

Show the history of an image

Options:
      --format string   Pretty-print images using a Go template
  -H, --human           Print sizes and dates in human readable format (default true)
      --no-trunc        Don't truncate output
  -q, --quiet           Only show numeric IDs

2.28帮助命令docker images --help

命令明细[参数明细]:

Usage:	docker images [OPTIONS] [REPOSITORY[:TAG]]

List images

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

2.29帮助命令docker import --help

命令明细[参数明细]:

Usage:	docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]

Import the contents from a tarball to create a filesystem image

Options:
  -c, --change list       Apply Dockerfile instruction to the created image
  -m, --message string    Set commit message for imported image
      --platform string   Set platform if server is multi-platform capable

2.30帮助命令docker info --help  

命令明细[参数明细]:

Usage:	docker info [OPTIONS]

Display system-wide information

Options:
  -f, --format string   Format the output using the given Go template

2.31帮助命令docker inspect --help

命令明细[参数明细]:

Usage:	docker inspect [OPTIONS] NAME|ID [NAME|ID...]

Return low-level information on Docker objects

Options:
  -f, --format string   Format the output using the given Go template
  -s, --size            Display total file sizes if the type is container
      --type string     Return JSON for specified type

2.32帮助命令docker kill --help

命令明细[参数明细]:

Usage:	docker kill [OPTIONS] CONTAINER [CONTAINER...]

Kill one or more running containers

Options:
  -s, --signal string   Signal to send to the container (default "KILL")

2.33帮助命令docker load --help   

命令明细[参数明细]:

Usage:	docker load [OPTIONS]

Load an image from a tar archive or STDIN

Options:
  -i, --input string   Read from tar archive file, instead of STDIN
  -q, --quiet          Suppress the load output

2.34帮助命令docker login --help

命令明细[参数明细]:

Usage:	docker login [OPTIONS] [SERVER]

Log in to a Docker registry.
If no server is specified, the default is defined by the daemon.

Options:
  -p, --password string   Password
      --password-stdin    Take the password from stdin
  -u, --username string   Username

2.35帮助命令docker logout --help

命令明细[参数明细]:

Usage:	docker logout [SERVER]

Log out from a Docker registry.
If no server is specified, the default is defined by the daemon.

2.36帮助命令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:37) or relative (e.g. 42m for 42 minutes)
      --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:37) or relative (e.g. 42m for 42 minutes)

2.37帮助命令docker pause --help  

命令明细[参数明细]:

Usage:	docker pause CONTAINER [CONTAINER...]

Pause all processes within one or more containers

2.38帮助命令docker port --help  

命令明细[参数明细]:

Usage:	docker port CONTAINER [PRIVATE_PORT[/PROTO]]

List port mappings or a specific mapping for the container

2.39帮助命令docker ps --help --help

命令明细[参数明细]:

Usage:	docker ps [OPTIONS]

List containers

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print containers using a Go template
  -n, --last int        Show n last created containers (includes all states) (default -1)
  -l, --latest          Show the latest created container (includes all states)
      --no-trunc        Don't truncate output
  -q, --quiet           Only display numeric IDs
  -s, --size            Display total file sizes

2.40帮助命令docker pull --help

命令明细[参数明细]:

Usage:	docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry

Options:
  -a, --all-tags                Download all tagged images in the repository
      --disable-content-trust   Skip image verification (default true)
      --platform string         Set platform if server is multi-platform capable
  -q, --quiet                   Suppress verbose output

2.41帮助命令docker push --help

命令明细[参数明细]:

Usage:	docker push [OPTIONS] NAME[:TAG]

Push an image or a repository to a registry

Options:
      --disable-content-trust   Skip image signing (default true)

2.42帮助命令docker rename --help

命令明细[参数明细]:

Usage:	docker rename CONTAINER NEW_NAME

Rename a container

2.43帮助命令docker restart --help

命令明细[参数明细]:

Usage:	docker restart [OPTIONS] CONTAINER [CONTAINER...]

Restart one or more containers

Options:
  -t, --time int   Seconds to wait for stop before killing the container (default 10)

2.44帮助命令docker rm --help --help

命令明细[参数明细]:

Usage:	docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers

Options:
  -f, --force     Force the removal of a running container (uses SIGKILL)
  -l, --link      Remove the specified link
  -v, --volumes   Remove anonymous volumes associated with the container

2.45帮助命令docker rmi --help

命令明细[参数明细]:

Usage:	docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Options:
  -f, --force      Force removal of the image
      --no-prune   Do not delete untagged parents

2.46帮助命令docker run --help

命令明细[参数明细]:

Usage:	docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup for the container
      --cidfile string                 Write the container ID to the file
      --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period in microseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  -c, --cpu-shares int                 CPU shares (relative weight)
      --cpus decimal                   Number of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                         Run container in background and print container ID
      --detach-keys string             Override the key sequence for detaching a container
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
      --device-write-iops list         Limit write rate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --domainname string              Container NIS domain name
      --entrypoint string              Overwrite the default ENTRYPOINT of the image
  -e, --env list                       Set environment variables
      --env-file list                  Read in a file of environment variables
      --expose list                    Expose a port or a range of ports
      --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
      --group-add list                 Add additional groups to join
      --health-cmd string              Command to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries int             Consecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname string                Container host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even if not attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc string                     IPC mode to use
      --isolation string               Container isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited file of labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver for the container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mount to the container
      --name string                    Assign a name to the container
      --network network                Connect a container to a network
      --network-alias list             Add network-scoped alias for the container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid string                     PID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 for unlimited)
      --platform string                Set platform if server is multi-platform capable
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rm                             Automatically remove the container when it exits
      --runtime string                 Runtime to use for this container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --sig-proxy                      Proxy received signals to the process (default true)
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (in seconds) to stop a container
      --storage-opt list               Storage driver options for the container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use
  -v, --volume list                    Bind mount a volume
      --volume-driver string           Optional volume driver for the container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir string                 Working directory inside the container

2.47帮助命令docker save --help

命令明细[参数明细]:

Usage:	docker save [OPTIONS] IMAGE [IMAGE...]

Save one or more images to a tar archive (streamed to STDOUT by default)

Options:
  -o, --output string   Write to a file, instead of STDOUT

2.48帮助命令docker search --help

命令明细[参数明细]:

Usage:	docker search [OPTIONS] TERM

Search the Docker Hub for images

Options:
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print search using a Go template
      --limit int       Max number of search results (default 25)
      --no-trunc        Don't truncate output

2.49帮助命令docker start --help  

命令明细[参数明细]:

Usage:	docker start [OPTIONS] CONTAINER [CONTAINER...]

Start one or more stopped containers

Options:
  -a, --attach                  Attach STDOUT/STDERR and forward signals
      --checkpoint string       Restore from this checkpoint
      --checkpoint-dir string   Use a custom checkpoint storage directory
      --detach-keys string      Override the key sequence for detaching a container
  -i, --interactive             Attach container's STDIN

2.50帮助命令docker stats --help

命令明细[参数明细]:

Usage:	docker stats [OPTIONS] [CONTAINER...]

Display a live stream of container(s) resource usage statistics

Options:
  -a, --all             Show all containers (default shows just running)
      --format string   Pretty-print images using a Go template
      --no-stream       Disable streaming stats and only pull the first result
      --no-trunc        Do not truncate output

2.51帮助命令docker stop --help  

命令明细[参数明细]:

Usage:	docker stop [OPTIONS] CONTAINER [CONTAINER...]

Stop one or more running containers

Options:
  -t, --time int   Seconds to wait for stop before killing it (default 10)

2.52帮助命令docker tag --help  

命令明细[参数明细]:

Usage:	docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

2.53帮助命令docker top --help  

命令明细[参数明细]:

Usage:	docker top CONTAINER [ps OPTIONS]

Display the running processes of a container

2.54帮助命令docker unpause --help

命令明细[参数明细]:

Usage:	docker unpause CONTAINER [CONTAINER...]

Unpause all processes within one or more containers

2.55帮助命令docker update --help

命令明细[参数明细]:

Usage:	docker update [OPTIONS] CONTAINER [CONTAINER...]

Update configuration of one or more containers

Options:
      --blkio-weight uint16        Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --cpu-period int             Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int              Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int          Limit the CPU real-time period in microseconds
      --cpu-rt-runtime int         Limit the CPU real-time runtime in microseconds
  -c, --cpu-shares int             CPU shares (relative weight)
      --cpus decimal               Number of CPUs
      --cpuset-cpus string         CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string         MEMs in which to allow execution (0-3, 0,1)
      --kernel-memory bytes        Kernel memory limit
  -m, --memory bytes               Memory limit
      --memory-reservation bytes   Memory soft limit
      --memory-swap bytes          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --pids-limit int             Tune container pids limit (set -1 for unlimited)
      --restart string             Restart policy to apply when a container exits

2.56帮助命令docker version --help

命令明细[参数明细]:

Usage:	docker version [OPTIONS]

Show the Docker version information

Options:
  -f, --format string       Format the output using the given Go template
      --kubeconfig string   Kubernetes config file

2.57帮助命令docker wait --help  

命令明细[参数明细]:

Usage:	docker wait CONTAINER [CONTAINER...]

Block until one or more containers stop, then print their exit codes

3.导出Docker命令明细脚本

导出Docker命令明细脚本,把每个命令详情生成到独立的指定文件中。

文件名:commandFile.sh

赋可执行权限:chmod a+x commandFile.sh

执行命令:./commandFile.sh

脚本内容:

#!/bin/bash
docker --help >> 1docker.txt
docker builder --help >> 2docker-builder.txt
docker config --help >>	3docker-config.txt
docker container --help >> 4docker-container.txt
docker context --help >> 5docker-context.txt
docker engine --help >>	6docker-engine.txt
docker image --help >> 7docker-image.txt
docker network --help >> 8docker-network.txt
docker node --help >> 9docker-node.txt
docker plugin --help >>	10docker-plugin.txt
docker secret --help >>	11docker-secret.txt
docker service --help >> 12docker-service.txt
docker stack --help >> 13docker-stack.txt
docker swarm --help >> 14docker-swarm.txt
docker system --help >>	15docker-system.txt
docker trust --help >> 16docker-trust.txt
docker volume --help >>	17docker-volume.txt
docker attach --help >>	18docker-attach.txt
docker build --help >> 19docker-build.txt
docker commit --help >>	20docker-commit.txt
docker cp --help >>	21docker-cp.txt.txt
docker create --help >>	22docker-create.txt
docker diff --help >> 23docker-diff.txt
docker events --help >>	24docker-events.txt
docker exec --help >> 25docker-exec.txt
docker export --help >>	26docker-export.txt
docker history --help >> 27docker-history.txt
docker images --help >>	28docker-images.txt
docker import --help >>	29docker-import.txt
docker info --help >> 30docker-info.txt
docker inspect --help >>31docker-inspect.txt
docker kill --help >> 32docker-kill.txt
docker load --help >> 33docker-load.txt
docker login --help >> 34docker-login.txt
docker logout --help >>	35docker-logout.txt
docker logs --help >> 36docker-logs.txt
docker pause --help >> 37docker-pause.txt
docker port --help >> 38docker-port.txt
docker ps --help >>	39docker-ps.txt.txt
docker pull --help >> 40docker-pull.txt
docker push --help >> 41docker-push.txt
docker rename --help >>	42docker-rename.txt
docker restart --help >> 43docker-restart.txt
docker rm --help >>	44docker-rm.txt.txt
docker rmi --help >> 45docker-rmi.txt
docker run --help >> 46docker-run.txt
docker save --help >> 47docker-save.txt
docker search --help >>	48docker-search.txt
docker start --help >> 49docker-start.txt
docker stats --help >> 50docker-stats.txt
docker stop --help >> 51docker-stop.txt
docker tag --help >> 52docker-tag.txt
docker top --help >> 53docker-top.txt
docker unpause --help >> 54docker-unpause.txt
docker update --help >>	55docker-update.txt
docker version --help >> 56docker-version.txt
docker wait --help >> 57docker-wait.txt

以上,感谢。

2022年12月20日

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值