【Docker】命令 info
阿新 • • 發佈:2020-10-23
參考教程:https://docs.docker.com/engine/reference/commandline/info/
環境
- virtual box 6.1
- centos 7.8
- docker 19.03
命令格式
docker info [OPTIONS]
此命令顯示有關 Docker 安裝的系統資訊。顯示的資訊包括核心版本,容器和映象數量。顯示的映象數量是唯一映象的數量。用不同名稱標記的同一個映象僅計算一次。如果指定了顯示的格式,則會按照指定的格式進行顯示。
根據所使用的儲存驅動,可以顯示其他額外的資訊,例如池名稱,資料檔案,元資料檔案,使用的資料空間,總資料空間,使用的元資料空間和總元資料空間。
資料檔案是儲存映象的位置,元資料檔案是儲存與那些映象有關的元資料的位置。首次執行時,Docker 將從 /var/lib/docker
的捲上的可用空間中分配一定數量的資料空間和元資料空間。
命令選項
format
根據指定的格式顯示輸出資訊,其中 -f
是 --format
的短命令形式。一般來說,在命令列手動輸入命令時,使用短命令形式,可以減少輸入。而長命令的形式,用在編寫指令碼的檔案中,增強可讀性。
示例
預設輸出
$ docker info Client: Debug Mode: false Plugins: app: Docker Application (Docker Inc., v0.8.0) buildx: Build with BuildKit (Docker Inc., v0.3.1-tp-docker) Server: Containers: 20 Running: 20 Paused: 0 Stopped: 0 Images: 31 Server Version: 19.03.6 Storage Driver: overlay Backing Filesystem: extfs Supports d_type: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657 init version: fec3683 Security Options: apparmor seccomp Profile: default Kernel Version: 4.15.0-88-generic Operating System: Ubuntu 18.04.4 LTS OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 2.403GiB Name: minikube ID: YI4C:27UO:6YUV:SOB6:SD7C:MHMS:JUDN:O46N:KUPH:SZDY:TGEA:WTEQ Docker Root Dir: /var/lib/docker Debug Mode: true File Descriptors: 129 Goroutines: 119 System Time: 2020-08-22T06:06:06.139588271Z EventsListeners: 0 Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: registry.test.training.katacoda.com:4567 127.0.0.0/8 Live Restore Enabled: false WARNING: No swap limit support WARNING: the overlay storage-driver is deprecated, and will be removed in a future release.
顯示 debug 資訊
$ docker -D info Client: Debug Mode: true Server: Containers: 14 Running: 3 Paused: 1 Stopped: 10 Images: 52 Server Version: 1.13.0 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: false Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Swarm: active ...
輸出 json 格式
$ docker info --format '{{json .}}'
{"ID":"I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S","Containers":14, ...}
核心警告
如果作業系統不支援某些功能,當你執行 docker info
的時候,你可能會看到以下警告之一:
- WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
- WARNING: No swap limit support
除非您確實需要限制這些資源的能力,否則您可以忽略這些警告,在這種情況下,應查閱作業系統的文件以啟用它們。
總結
介紹了 info 命令的使用,可以輸出 docker 和系統的一些資訊。介紹了 --format
選項的作用,可以獲取指定的值,也可以對輸出的內容進行格式化。