docker基本命令筆記第一冊

我可是千機傘發表於2020-09-23

1.docker –help

當你忘記一些命令的時候可以用這個指令來得到幫助

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

2.docker run xxx

這是啟動一個容器的指令,xxx為容器的名字
如果本地docker沒有此容器,則會先去倉庫拉取映象,倉庫若是沒有該映象則報錯

-it:例如docker run - it centos /bin/bash ,即為在當前終端以bash執行容器。
-d:則在後臺執行容器
-c:執行容器並給她寫入shell指令碼

3.docker search xxx

從docker倉庫尋找映象

--filter:使用過濾器過濾一些查詢資訊
例如docker search centos --filter=STARS=1000
就是尋找stars 一千+的映象 

4.docker pull xxx

從docker倉庫拉取映象

5.docker ps

檢視正在執行的容器

-a:檢視所有的容器,包括停止的
-p:檢視所有的容器的ports

6.docker images

檢視所有的映象

--filter:使用過濾器過濾一些查詢資訊
-a:檢視所有的映象,包括停止的
-p:檢視所有的映象的ports

7.docker start/restart/stop/kill xxx

分別為,開啟一個容器,重啟一個容器,關閉一個容器,強制殺死一個容器

8.docker exec/attach xxx

分別為在新終端進入容器,和在本終端進入容器

9.docker rm/rmi

分別為刪除,和刪除一個映象

-f 刪除所有 
#事例 刪除所有容器
docker rm -f $(docker ps -aq)

10 docker cp xxx:/容器路徑 /宿主機路徑

從容器中複製檔案到宿主機中。
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章