第四章 Docker命令匯總

請(qǐng)注意Docker新舊版本命令格式使用方法不同,但新版本兼容老版本的命令格式。
本章只是做Docker命令匯總,看著如果比較枯燥,可以查看后續(xù)文章中的詳細(xì)案例與介紹。
在后續(xù)的文章中,會(huì)以實(shí)際案例對(duì)各個(gè)命令進(jìn)行詳細(xì)解釋說(shuō)明。

Docker命令概述:

# 命令行直接鍵入docker,查看docker命令文檔:
[root@centos_7_1]:[~]# docker
# Docker客戶端命令的用法:
Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers
# 選項(xiàng):
Options:
      --config string      Location of client config files (default "/root/.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 "/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
# 新版本的Docker支持按分類查看命令:
Management Commands:
  config      Manage Docker configs     # 管理Docker配置
  container   Manage containers         # 管理容器
  image       Manage images             # 管理鏡像
  network     Manage networks           # 管理網(wǎng)絡(luò)
  node        Manage Swarm nodes        # 
  plugin      Manage plugins            # 管理插件
  secret      Manage Docker secrets     # 
  service     Manage services           # 管理服務(wù)
  stack       Manage Docker stacks      # 
  swarm       Manage Swarm              #
  system      Manage Docker             # 管理Docker系統(tǒng)
  trust       Manage trust on Docker images     # 管理對(duì)Docker信任的鏡像
  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容器幫助文檔:
[root@centos_7_1]:[~]# docker container --help
# Docker容器命令的用法:
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.

二、Docker鏡像命令

[root@centos_7_1]:[~]# 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.

三、Docker網(wǎng)絡(luò)命令

[root@centos_7_1]:[~]# 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.

Docker分類---文章目錄:

第一章 初識(shí)Docker | 點(diǎn)擊此處
第二章 安裝Docker以及簡(jiǎn)單配置 | 點(diǎn)擊此處
第三章 Docker容器的生命周期 | 點(diǎn)擊此處
第四章 Docker命令匯總 | 點(diǎn)擊此處
第五章 Docker基礎(chǔ)命令詳解 | 點(diǎn)擊此處
第六章 Docker---鏡像的命令詳解 | 點(diǎn)擊此處
第七章 Docker---容器的命令詳解 | 點(diǎn)擊此處
第八章 Docker與Alpine不解之緣 | 點(diǎn)擊此處
未完待續(xù)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容