Docker容器系列文章|這20個Docker Command,有幾個是你會的?

民工哥技術之路 發表於 2019-09-17

在這之前呢,也寫過兩篇關於Docker基礎入門類的文章

Docker容器技術入門(一)

Docker容器技術入門(二)

很多人都感覺這文章這麼簡單、這麼基礎,可是別忘記了“萬丈高樓平地起”,如果少了這個平地址,你這高樓估計也起不了。所以,基礎是學習任何一門技術或者一個技術點的重中之重,也可以說是很關鍵的決勝點。

所以呢,今天,民工哥給大家總結了這20個Docker Command,願各位小夥伴在通往“玩轉Docker”路上不再無助!!!!

安裝完成docker容器服務之後,需要了解如何操作它?在shell命令列下直接輸入docker就可以檢視幫助資訊,如下。

[[email protected] ~]# docker
Usage:    docker COMMAND
A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/root/.docker")
  -D, --debug              Enable debug mode
      --help               Print usage
  -H, --host list          Daemon socket(s) to connect to (default [])
  -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:
  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
  volume      Manage volumes

Commands:
  attach      Attach 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 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

1、docker start/stop/restart/kill

啟動/停止/重啟/殺掉容器

例項操作如下:

[[email protected] ~]# docker start myweb
[[email protected] ~]# docker stop myweb
[[email protected] ~]# docker restart myweb
[[email protected] ~]# docker kill -s kill myweb

引數 -s #向容器傳送訊號
這些命令不做過多解釋

2、docker run

建立並啟動一個新的容器

常用引數如下:
-d              #後臺執行容器,並返回容器ID
-i              #以互動式模式執行容器,常與-t引數同時使用
-t              #給容器重新分配一個偽終端,常與-i引數同時使用
--name          #給容器指定一個名稱
-m              #指定容器使用記憶體的最大值
--net           #指定容器使用的網路型別
--link          #連結到另一個容器

例項操作如下:

[[email protected] ~]# docker run -d --name nginx nginx:latest
#後臺啟動並執行一個名為nginx的容器,執行前它會自動去docker映象站點下載最新的映象檔案

[[email protected] ~]# docker run -d -P 80:80 nginx:latest
#後臺啟動並運名為nginx的容器,然後將容器的80埠對映到物理機的80埠

[[email protected] ~]# docker run -d -v /docker/data:/docker/data -P 80:80 nginx:latest
#後臺啟動並運名為nginx的容器,然後將容器的80埠對映到物理機的80埠,並且將物理機的/docker/data目錄對映到容器的/docker/data

[[email protected] ~]# docker run -it  nginx:latest /bin/bash
#以互動式模式執行容器,然後在容器內執行/bin/bash命令

3、docker rm

刪除容器

常用引數如下:
-f     #強制刪除一個執行中的容器
-l     #刪除指定的連結
-v     #刪除與容器關聯和卷

例項操作如下:

[[email protected] ~]# docker rm -f mydocker
#強制刪除容器mydocker

[[email protected] ~]# docker rm -f dockerA dockerB
#強制刪除容器dockerA,dockerB

[[email protected] ~]# docker rm -v mydocker
#刪除容器,並刪除容器掛載的資料卷

4、docker create

建立一個新的容器但不啟動它

[[email protected] ~]# docker create --name myserver nginx:latest
09b93464c2f75b7b69f83d56a9cfc23ceb50a48a9db7652ee4c27e3e2cb1961f
#建立一個名為myserver的容器

5、docker exec

在執行的容器中執行命令

常用引數如下:
-d      #在後臺執行
-i      #保持STDIN開啟
-t      #分配一個偽終端

例項操作如下:

[[email protected] ~]# docker exec -it mydocker /bin/sh /server/scripts/docker.sh
hello world!!!!!!!!!!
#以互動模式執行容器中的/server/scripts/docker.sh指令碼
[[email protected] ~]# docker exec -it mydocker /bin/sh 
[email protected]:/#
#以互動模式給容器分配一個偽終端連線

6、docker ps

列出容器(正在執行)

常用引數如下:
-a      #列出所有容器包括停止的
-f      #根據條件過濾顯示內容
-l      #列出最近建立的容器
-n      #列出最近建立的N個容器,N為數字
-q      #只顯示容器ID
-s      #顯示總檔案大小

例項操作如下:

[[email protected] ~]# docker ps
CONTAINER ID  IMAGE            COMMAND                  CREATED       STATUS       PORTS                                            NAMES
bd96d72ed9c7  google/cadvisor  "/usr/bin/cadvisor..."   47 hours ago  Up 47 hours  0.0.0.0:8082->8080/tcp                           cadvisor
665563143eb7  grafana/grafana  "/run.sh"                2 days ago    Up 2 days    0.0.0.0:3000->3000/tcp                           grafana
f2304dad5855  tutum/influxdb   "/run.sh"                2 days ago    Up 2 days    0.0.0.0:8083->8083/tcp, 0.0.0.0:8086->8086/tcp   influxdb
#列出正在執行的容器

[[email protected] ~]# docker ps -n 2
CONTAINER ID   IMAGE               COMMAND                  CREATED       STATUS       PORTS                    NAMES
bd96d72ed9c7   google/cadvisor     "/usr/bin/cadvisor..."   47 hours ago  Up 47 hours  0.0.0.0:8082->8080/tcp   cadvisor
665563143eb7   grafana/grafana     "/run.sh"                2 days ago    Up 2 days    0.0.0.0:3000->3000/tcp   grafana
#列出最近建立的2個容器

[[email protected] ~]# docker ps -a -q
bd96d72ed9c7
665563143eb7
f2304dad5855
9921d2660307
#顯示所有容器的ID

7、docker inspect

獲取容器的後設資料

常用引數如下:
-f        #指定返回值格式或模板檔案
-s        #顯示總檔案大小
--type    #為指定型別返回JSON

例項操作如下:

[[email protected] ~]# docker inspect bd96d72ed9c7
[
    {
        "Id": "bd96d72ed9c713591ba8db0ed4c0ae2689188255da71033c7bced6bb34aa8542",
        "Created": "2018-05-23T09:22:10.633809699Z",
        "Path": "/usr/bin/cadvisor",
        "Args": [
            "-logtostderr",
            "-storage_driver=influxdb",
            "-storage_driver_db=cadvisor",
            "-storage_driver_host=192.168.3.82:8086"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 17589,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-05-23T09:22:10.769771142Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:75f88e3ec333cbb410297e4f40297ac615e076b4a50aeeae49f287093ff01ab1",
        "ResolvConfPath": "/var/lib/docker/containers/bd96d72ed9c713591ba8db0ed4c0ae2689188255da71033c7bced6bb34aa8542/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/bd96d72ed9c713591ba8db0ed4c0ae2689188255da71033c7bced6bb34aa8542/hostname",
        "HostsPath": "/var/lib/docker/containers/bd96d72ed9c713591ba8db0ed4c0ae2689188255da71033c7bced6bb34aa8542/hosts",
        "LogPath": "",
        "Name": "/cadvisor",
        "RestartCount": 0,
        "Driver": "overlay2",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/:/rootfs,ro",
                "/var/run:/var/run",
-------------------------------------------省略部分內容
#獲取容器ID為bd96d72ed9c7的後設資料資訊

[[email protected] ~]# docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cadvisor
172.17.0.3
[[email protected] ~]# docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' influxdb
172.17.0.2
#獲取容器名為influxdb\cadvisor的IP地址

8、docker logs

獲取容器的日誌

常用引數如下:
-f        #跟蹤日誌輸出
-t        #顯示時間戳
--tail    #只顯示最新n條容器日誌
--since   #顯示某個開始時間的所有日誌

例項操作如下:

[[email protected] ~]# docker logs -f cadvisor
I0523 09:22:10.794233       1 storagedriver.go:48] Using backend storage type "influxdb"
I0523 09:22:10.794295       1 storagedriver.go:50] Caching stats in memory for 2m0s
I0523 09:22:10.794551       1 manager.go:151] cAdvisor running in container: "/sys/fs/cgroup/cpuacct,cpu"
I0523 09:22:10.810585       1 fs.go:139] Filesystem UUIDs: map[]
I0523 09:22:10.810599       1 fs.go:140] Filesystem partitions: map[shm:{mountpoint:/dev/shm major:0 minor:47 fsType:tmpfs blockSize:0} overlay:{mountpoint:/ major:0 minor:46 fsType:overlay blockSize:0} tmpfs:{mountpoint:/dev major:0 minor:50 fsType:tmpfs blockSize:0} /dev/mapper/centos-root:{mountpoint:/rootfs,ro major:253 minor:0 fsType:xfs blockSize:0} /dev/sda1:{mountpoint:/rootfs,ro/boot major:8 minor:1 fsType:xfs blockSize:0} /dev/mapper/centos-home:{mountpoint:/rootfs,ro/home major:253 minor:2 fsType:xfs blockSize:0}]
W0523 09:22:10.812419       1 info.go:52] Couldn't collect info from any of the files in "/etc/machine-id,/var/lib/dbus/machine-id"
I0523 09:22:10.812460       1 manager.go:225] Machine: {NumCores:1 CpuFrequency:2799091 MemoryCapacity:8203235328 HugePages:[{PageSize:2048 NumPages:0}] MachineID: SystemUUID:564D5235-FED8-3630-AA2B-D65F0855D036 BootID:fd7b3fb5-e74f-4280-80cf-0a7096239619 Filesystems:[{Device:tmpfs DeviceMajor:0 DeviceMinor:50 Capacity:4101615616 Type:vfs Inodes:1001371 HasInodes:true} {Device:/dev/mapper/centos-root DeviceMajor:253 DeviceMinor:0 Capacity:140633964544 Type:vfs Inodes:68681728 HasInodes:true} {Device:/dev/sda1 DeviceMajor:8 DeviceMinor:1 Capacity:1063256064 Type:vfs Inodes:524288 HasInodes:true} {Device:/dev/mapper/centos-home DeviceMajor:253 DeviceMinor:2 Capacity:21464350720 Type:vfs Inodes:10485760 HasInodes:true} {Device:shm DeviceMajor:0 DeviceMinor:47 Capacity:67108864 Type:vfs Inodes:1001371 HasInodes:true} {Device:overlay DeviceMajor:0 DeviceMinor:46 Capacity:140633964544 Type:vfs Inodes:68681728 HasInodes:true}] DiskMap:map[253:0:{Name:dm-0 Major:253 Minor:0 Size:140660178944 Scheduler:none} 253:1:{Name:dm-1 Major:253 Minor:1 Size:8455716864 Scheduler:none} 253:2:{Name:dm-2 Major:253 Minor:2 Size:21474836480 Scheduler:none} 2:0:{Name:fd0 Major:2 Minor:0 Size:4096 Scheduler:deadline} 8:0:{Name:sda Major:8 Minor:0 Size:171798691840 Scheduler:deadline}] NetworkDevices:[{Name:eth0 MacAddress:02:42:ac:11:00:03 Speed:10000 Mtu:1500}] Topology:[{Id:0 Memory:8589467648 Cores:[{Id:0 Threads:[0] Caches:[{Size:32768 Type:Data Level:1} {Size:32768 Type:Instruction Level:1} {Size:262144 Type:Unified Level:2}]}] Caches:[{Size:26214400 Type:Unified Level:3}]}] CloudProvider:Unknown InstanceType:Unknown InstanceID:None}
#跟蹤檢視容器cadvisor的日誌

9、docker port

顯示指定容器的埠對映

例項操作如下:

[[email protected] ~]# docker port cadvisor
8080/tcp -> 0.0.0.0:8082
#顯示cadvisor容器的埠對映資訊

10、docker commit

用已存在的容器重新建立一個新的映象

常用引數如下:
-a      #提交的映象作者
-c      #使用Dockerfile指令來建立映象
-m      #提交時附上說明文字
-p      #在commit時,將容器暫停

例項操作如下:

[[email protected] ~]# docker commit -a "mingongge" -m "add a new images" bd96d72ed9c7  newdocker_images:v1.0.0
sha256:20ee805752cb7cae660fbae89d7c6ea4a9c6372f16a6cb079ecf6c79f87ed8c9
[[email protected] ~]# docker images
REPOSITORY          TAG       IMAGE ID       CREATED        SIZE
newdocker_images    v1.0.0    20ee805752cb   7 seconds ago  62.2 MB
#將容器bd96d72ed9c7重新生成一個新的映象名為newdocker_images

11、docker cp

用於容器與物理主機之間拷貝檔案

例項操作如下:

[[email protected] ~]# docker cp /data/index.html bd96d72ed9c7:/web/
#將物理主機中的/data/index.html拷貝到容器bd96d72ed9c7:/web/目錄下

[[email protected] ~]# docker cp /data/index.html bd96d72ed9c7:/web/index.php
#將物理主機中的/data/index.html拷貝到容器bd96d72ed9c7:/web/目錄下並改名為index.php

[[email protected] ~]# docker cp  bd96d72ed9c7:/web  /data/
#拷貝容器bd96d72ed9c7:/web/目錄到物理主機中的/data/目錄下

12、docker login/logout

用於登入與登出容器映象倉庫

docker login       
#登陸到一個Docker映象倉庫,如果未指定映象倉庫地址,預設為官方倉庫 Docker Hub

docker logout      
#登出一個Docker映象倉庫,如果未指定映象倉庫地址,預設為官方倉庫 Docker Hub

常用引數如下:
-u      #登陸的使用者名稱
-p      #登陸的密碼

例項操作如下:

[[email protected] ~]# docker login -u username -p password
Login Succeeded
[[email protected] ~]# docker logout
Removing login credentials for https://index.docker.io/v1/
#登入與登出預設的容器映象倉庫

13、docker pull/push

docker pull    #從映象倉庫中拉取或者更新指定映象
docker push    #將本地的映象上傳到映象倉庫,要先登陸到映象倉庫

例項操作如下:

[[email protected] ~]# docker  pull  nginx
Using default tag: latest
Trying to pull repository docker.io/library/nginx ... 
latest: Pulling from docker.io/library/nginx
f2aa67a397c4: Already exists 
3c091c23e29d: Pulling fs layer 
4a99993b8636: Pulling fs layer
#從映象倉庫中拉取或者更新指定映象,輸出資訊如上

[[email protected] ~]# docker push newdocker_images:v1.0.0
#上傳映象到映象倉庫上

14、docker images

顯示系統本地容器映象檔案

常用引數如下:
-a                #列出所有的映象(含中間映像層,預設,過濾掉中間映像層);
--digests         #顯示映象的摘要資訊;
-f                #顯示滿足條件的映象;
--format          #指定返回值的模板檔案;
--no-trunc        #顯示完整的映象資訊;
-q                #只顯示映象ID。

例項操作如下:

[[email protected] ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
newdocker_images                           v1.0.0    20ee805752cb   28 minutes ago  62.2 MB
docker.io/grafana/grafana                  latest    4700307f41f2   9 days ago      238 MB
registry.jumpserver.org/public/guacamole   1.0.0     6300349f2642   2 months ago    1.23 GB
docker.io/google/cadvisor                  latest    75f88e3ec333   5 months ago    62.2 MB
docker.io/tutum/influxdb                   latest    c061e5808198   19 months ago   290 MB
#列出本地所有的映象

[[email protected] ~]# docker images -q
20ee805752cb
4700307f41f2
6300349f2642
75f88e3ec333
c061e5808198
#只顯示容器ID

[[email protected] ~]# docker images --digests
REPOSITORY                                 TAG      DIGEST                                                                    IMAGE ID        CREATED         SIZE
newdocker_images                           v1.0.0   <none>                                                                    20ee805752cb    32 minutes ago  62.2 MB
docker.io/grafana/grafana                  latest   sha256:364bec4a39ecbec744ea4270aae35f6554eb6f2047b3ee08f7b5f1134857c32c   4700307f41f2    9 days ago      238 MB
registry.jumpserver.org/public/guacamole   1.0.0    sha256:ea862bb2e83b648701655c27900bca14b0ab7ab9d4572e716c25a816dc55307b   6300349f2642    2 months ago    1.23 GB
docker.io/google/cadvisor                  latest   sha256:9e347affc725efd3bfe95aa69362cf833aa810f84e6cb9eed1cb65c35216632a   75f88e3ec333    5 months ago    62.2 MB
docker.io/tutum/influxdb                   latest   sha256:5b7c5e318303ad059f3d1a73d084c12cb39ae4f35f7391b79b0ff2c0ba45304b   c061e5808198    19 months ago   290 MB
[[email protected] ~]# docker images --no-trunc                                                                                                     
REPOSITORY                                 TAG      IMAGE ID                                                                  CREATED         SIZE
newdocker_images                           v1.0.0   sha256:20ee805752cb7cae660fbae89d7c6ea4a9c6372f16a6cb079ecf6c79f87ed8c9   32 minutes ago  62.2 MB
docker.io/grafana/grafana                  latest   sha256:4700307f41f249630f6d772638ad8d32c7d7e3ec86c324d449d5e21076991bb7   9 days ago      238 MB
registry.jumpserver.org/public/guacamole   1.0.0    sha256:6300349f264218e783cd2bd6f7863d356ac8d5ac05a62584cb4680af7ebec292   2 months ago    1.23 GB
docker.io/google/cadvisor                  latest   sha256:75f88e3ec333cbb410297e4f40297ac615e076b4a50aeeae49f287093ff01ab1   5 months ago    62.2 MB
docker.io/tutum/influxdb                   latest   sha256:c061e580819875fad91910841fd3fc53893524bbb9326a68b2470861633aebb1   19 months ago   290 MB
#可以對比下兩個引數顯示的不同資訊

15、docker rmi

刪除映象

常用引數如下:
-f      #強制刪除

例項操作如下:

[[email protected] ~]# docker images
REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
newdocker_images                           v1.1.0    858cbd9ba687   6 seconds ago   62.2 MB
newdocker_images                           v1.0.0    20ee805752cb   36 minutes ago  62.2 MB
docker.io/grafana/grafana                  latest    4700307f41f2   9 days ago      238 MB
registry.jumpserver.org/public/guacamole   1.0.0     6300349f2642   2 months ago    1.23 GB
docker.io/google/cadvisor                  latest    75f88e3ec333   5 months ago    62.2 MB
docker.io/tutum/influxdb                   latest    c061e5808198   19 months ago   290 MB
[[email protected] ~]# docker rmi 20ee805752cb
Untagged: newdocker_images:v1.0.0
Deleted: sha256:20ee805752cb7cae660fbae89d7c6ea4a9c6372f16a6cb079ecf6c79f87ed8c9
[[email protected] ~]# docker images
REPOSITORY                                 TAG       IMAGE ID      CREATED          SIZE
newdocker_images                           v1.1.0    858cbd9ba687  39 seconds ago   62.2 MB
docker.io/grafana/grafana                  latest    4700307f41f2  9 days ago       238 MB
registry.jumpserver.org/public/guacamole   1.0.0     6300349f2642  2 months ago     1.23 GB
docker.io/google/cadvisor                  latest    75f88e3ec333  5 months ago     62.2 MB
docker.io/tutum/influxdb                   latest    c061e5808198  19 months ago    290 MB
#刪除一個映象

16、docker tag

標記本地映象

例項操作如下:

[[email protected] ~]# docker images
REPOSITORY           TAG        IMAGE ID            CREATED             SIZE
newdocker_images     v1.1.0     858cbd9ba687        39 seconds ago      62.2 MB
[[email protected] ~]# docker tag newdocker_images:v1.1.0 newdocker_images:v2
[[email protected] ~]# docker images
REPOSITORY           TAG        IMAGE ID            CREATED             SIZE
newdocker_images     v1.1.0     858cbd9ba687        4 minutes ago       62.2 MB
newdocker_images     v2         858cbd9ba687        4 minutes ago       62.2 MB
#從結果可以看出兩個容器的ID是一樣的,只是TAG改變了,類似於linux中檔案與檔案的硬連結一樣,其兩者的inode號相同。

17、docker build :

使用Dockerfile建立映象

常用引數如下:
-f                    #指定要使用的Dockerfile路徑
--label=[]            #設定映象使用的後設資料;
-m                    #設定記憶體最大值
--memory-swap         #設定Swap的最大值為記憶體+swap,"-1"表示不限swap
--no-cache           #建立映象的過程不使用快取
--pull               #嘗試去更新映象的新版本
-q                   #安靜模式,成功後只輸出映象ID
--rm                 #設定映象成功後刪除中間容器
--ulimit            #Ulimit配置

例項操作如下:

[[email protected] ~]# docker build https://github.com/nginxinc/docker-nginx/

18、docker history

檢視指定映象的建立歷史

常用引數如下:
-H               #以可讀的格式列印映象大小和日期,預設為true;
--no-trunc       #顯示完整的提交記錄;
-q               #僅列出提交記錄ID。

例項操作如下:

[[email protected] ~]# docker history newdocker_images:v2
IMAGE             CREATED          CREATED BY                                    SIZE      COMMENT
858cbd9ba687    32 minutes ago   -storage_driver=influxdb -storage_driver_d...   0 B       add new images
75f88e3ec333    5 months ago     /bin/sh -c #(nop)  ENTRYPOINT ["/usr/bin/c...   0 B       
<missing>       5 months ago     /bin/sh -c #(nop)  EXPOSE 8080/tcp              0 B       
<missing>       5 months ago     /bin/sh -c #(nop) ADD file:e138bb5c0c12107...   26.5 MB   
<missing>       5 months ago     /bin/sh -c apk --no-cache add ca-certifica...   30.9 MB   
<missing>       5 months ago     /bin/sh -c #(nop)  ENV GLIBC_VERSION=2.23-r3    0 B       
<missing>       5 months ago     /bin/sh -c #(nop)  MAINTAINER [email protected]   0 B       
<missing>       5 months ago     /bin/sh -c #(nop)  CMD ["/bin/sh"]              0 B       
<missing>       5 months ago     /bin/sh -c #(nop) ADD file:c05a199f603e2a9...   4.82 MB 

19、docker info

顯示 Docker 系統資訊,包括映象和容器數

例項操作如下:

[[email protected] ~]# docker info
Containers: 4
 Running: 3
 Paused: 0
 Stopped: 1
Images: 5
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: e9c345b3f906d5dc5e8100b05ce37073a811c74a (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: 5b117de7f824f3d3825737cf09581645abbe35d4 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  WARNING: You're not using the default seccomp profile
  Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-693.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 1
Total Memory: 7.64 GiB
Name: docker
ID: K7N6:CHF5:KAZP:QFDB:VYBP:IWMW:7VMV:L4TB:OJD2:SEZI:YRRR:4TJN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Registries: docker.io (secure)

20、docker version

顯示 Docker 版本資訊

例項操作如下:

[[email protected] ~]# docker version
Client:
 Version:         1.13.1
 API version:     1.26
 Package version: docker-1.13.1-63.git94f4240.el7.centos.x86_64
 Go version:      go1.9.4
 Git commit:      94f4240/1.13.1
 Built:           Fri May 18 15:44:33 2018
 OS/Arch:         linux/amd64

Server:
 Version:         1.13.1
 API version:     1.26 (minimum version 1.12)
 Package version: docker-1.13.1-63.git94f4240.el7.centos.x86_64
 Go version:      go1.9.4
 Git commit:      94f4240/1.13.1
 Built:           Fri May 18 15:44:33 2018
 OS/Arch:         linux/amd64
 Experimental:    false

更多精彩乾貨請關注民工哥個人微信公眾號:民工哥技術之路
圖片描述


相關文章

Docker 常用命令 Docker

Docker 常用命令

學習完整課程請移步 網際網路 Java 全棧工程師檢視 Docker 版本docker version從 Docker 檔案構建 Docker 映像docker build -t image-name
docker 安裝 Docker

docker 安裝

安裝 Dockeryum -y install docker啟動 Docker 後臺服務service docker start安裝mongodbdocker pull mongodocker ru
Docker Compose Docker

Docker Compose

Docker Compose1. Docker Compose 可以做什麼?主要是解決容器管理的問題。舉個例子,一個小型的 LNMP 網站,需要 Linux 容器,Nginx 容器,MySQL容器,P
Docker 容器學習 Docker

Docker 容器學習

一、Docker 容器的安裝# mac 環境安裝$ brew cask install docker# centos7 環境安裝$ sudo yum remove docker \
詳解Docker容器視覺化監控中心搭建 Docker|視覺化

詳解Docker容器視覺化監控中心搭建

概述一個宿主機上可以執行多個容器化應用,容器化應用執行於宿主機上,我們需要知道該容器的執行情況,包括 CPU使用率、記憶體佔用、網路狀況以及磁碟空間等等一系列資訊,而且這些資訊隨時間變化,我們稱其為時
docker 安裝 Redis 主從容器 Redis|Docker

docker 安裝 Redis 主從容器

建立Dockerfile 檔案FROM centos:latestRUN groupadd -r redis &amp;&amp; useradd -r -g redis redisRUN yum
docker  配置 Redis 主從 Redis|Docker

docker 配置 Redis 主從

配置主從有三種方式(1)配置檔案 在從伺服器的配置檔案中加入:slaveof &lt;masterip&gt; &lt;masterport&gt; (2)啟動命令 redis-server啟動命令後
Docker 基礎學習 Docker

Docker 基礎學習

可以理解為全新的虛擬機器容器環境: CentOS 7.x首先更新yum: sudo yum -y update然後執行安裝命令:sudo yum install -y dockerDocker預設位置
Docker Swarm 叢集搭建實踐 Docker

Docker Swarm 叢集搭建實踐

說明Docker Swarm 是 Docker 的一個原生的叢集管理工具,可以把多個Docker主機(節點)組織成一個叢集,使得容器可以組成跨主機的子網網路,此外,Docker Swarm 還內建了部
docker 實現 Redis 的哨兵機制 Redis|Docker

docker 實現 Redis 的哨兵機制

redis 哨兵的由來redis 的主從都需要人工來切換,如果生成環境中 redis 主伺服器 掛掉了,無法提供服務。 這時候需要人工自動把從伺服器設定 主伺服器; 這個方法就會存在一定弊端,導致無法
docker刪除所有容器和映象命令 Docker

docker刪除所有容器和映象命令

刪除容器需要先停止後remove:# docker stop $(docker ps -a -q)a679aa25d419d6f061600581a1fc78352ff1fdb3718b8ad1348
修改 Docker 容器對映的埠 Docker

修改 Docker 容器對映的埠

前言就執行中的容器而言,對於資源性的修改可以直接使用 docker update 進行改動,但是對映的埠、掛載等不可通過指令修改,雖然可以刪除容器再新建一個新的容器,除了此方案還可以修改容器的執行時配