背景说明

解决方案

帮助命令

  1. [root@template ~]# docker help
  2. Usage: docker [OPTIONS] COMMAND
  3. A self-sufficient runtime for containers
  4. Options:
  5. --config string Location of client config files (default "/root/.docker")
  6. -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")
  7. -D, --debug Enable debug mode
  8. -H, --host list Daemon socket(s) to connect to
  9. -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
  10. --tls Use TLS; implied by --tlsverify
  11. --tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
  12. --tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
  13. --tlskey string Path to TLS key file (default "/root/.docker/key.pem")
  14. --tlsverify Use TLS and verify the remote
  15. -v, --version Print version information and quit
  16. Management Commands:
  17. app* Docker App (Docker Inc., v0.9.1-beta3)
  18. builder Manage builds
  19. buildx* Docker Buildx (Docker Inc., v0.8.1-docker)
  20. config Manage Docker configs
  21. container Manage containers
  22. context Manage contexts
  23. image Manage images
  24. manifest Manage Docker image manifests and manifest lists
  25. network Manage networks
  26. node Manage Swarm nodes
  27. plugin Manage plugins
  28. scan* Docker Scan (Docker Inc., v0.17.0)
  29. secret Manage Docker secrets
  30. service Manage services
  31. stack Manage Docker stacks
  32. swarm Manage Swarm
  33. system Manage Docker
  34. trust Manage trust on Docker images
  35. volume Manage volumes
  36. Commands:
  37. attach Attach local standard input, output, and error streams to a running container
  38. build Build an image from a Dockerfile
  39. commit Create a new image from a container's changes
  40. cp Copy files/folders between a container and the local filesystem
  41. create Create a new container
  42. diff Inspect changes to files or directories on a container's filesystem
  43. events Get real time events from the server
  44. exec Run a command in a running container
  45. export Export a container's filesystem as a tar archive
  46. history Show the history of an image
  47. images List images
  48. import Import the contents from a tarball to create a filesystem image
  49. info Display system-wide information
  50. inspect Return low-level information on Docker objects
  51. kill Kill one or more running containers
  52. load Load an image from a tar archive or STDIN
  53. login Log in to a Docker registry
  54. logout Log out from a Docker registry
  55. logs Fetch the logs of a container
  56. pause Pause all processes within one or more containers
  57. port List port mappings or a specific mapping for the container
  58. ps List containers
  59. pull Pull an image or a repository from a registry
  60. push Push an image or a repository to a registry
  61. rename Rename a container
  62. restart Restart one or more containers
  63. rm Remove one or more containers
  64. rmi Remove one or more images
  65. run Run a command in a new container
  66. save Save one or more images to a tar archive (streamed to STDOUT by default)
  67. search Search the Docker Hub for images
  68. start Start one or more stopped containers
  69. stats Display a live stream of container(s) resource usage statistics
  70. stop Stop one or more running containers
  71. tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  72. top Display the running processes of a container
  73. unpause Unpause all processes within one or more containers
  74. update Update configuration of one or more containers
  75. version Show the Docker version information
  76. wait Block until one or more containers stop, then print their exit codes
  77. Run 'docker COMMAND --help' for more information on a command.
  78. To get more help with docker, check out our guides at https://docs.docker.com/go/guides/
  79. [root@template ~]# s

帮助文档

  1. [root@template ~]# docker images --help
  2. Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
  3. List images
  4. Options:
  5. -a, --all Show all images (default hides intermediate images)
  6. --digests Show digests
  7. -f, --filter filter Filter output based on conditions provided
  8. --format string Pretty-print images using a Go template
  9. --no-trunc Don't truncate output
  10. -q, --quiet Only show image IDs
  11. [root@template ~]#

版本信息

  1. [root@template ~]# docker -v
  2. Docker version 20.10.14, build a224086
  3. [root@template ~]#

版本详情

  1. [root@template ~]# docker version
  2. Client: Docker Engine - Community
  3. Version: 20.10.14
  4. API version: 1.41
  5. Go version: go1.16.15
  6. Git commit: a224086
  7. Built: Thu Mar 24 01:49:57 2022
  8. OS/Arch: linux/amd64
  9. Context: default
  10. Experimental: true
  11. Server: Docker Engine - Community
  12. Engine:
  13. Version: 20.10.14
  14. API version: 1.41 (minimum version 1.12)
  15. Go version: go1.16.15
  16. Git commit: 87a90dc
  17. Built: Thu Mar 24 01:48:24 2022
  18. OS/Arch: linux/amd64
  19. Experimental: false
  20. containerd:
  21. Version: 1.5.11
  22. GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
  23. runc:
  24. Version: 1.0.3
  25. GitCommit: v1.0.3-0-gf46b6ba
  26. docker-init:
  27. Version: 0.19.0
  28. GitCommit: de40ad0

概要信息

  1. [root@template ~]# docker info
  2. Client:
  3. Context: default
  4. Debug Mode: false
  5. Plugins:
  6. app: Docker App (Docker Inc., v0.9.1-beta3)
  7. buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
  8. scan: Docker Scan (Docker Inc., v0.17.0)
  9. Server:
  10. Containers: 3
  11. Running: 1
  12. Paused: 0
  13. Stopped: 2
  14. Images: 2
  15. Server Version: 20.10.14
  16. Storage Driver: overlay2
  17. Backing Filesystem: xfs
  18. Supports d_type: true
  19. Native Overlay Diff: true
  20. userxattr: false
  21. Logging Driver: json-file
  22. Cgroup Driver: cgroupfs
  23. Cgroup Version: 1
  24. Plugins:
  25. Volume: local
  26. Network: bridge host ipvlan macvlan null overlay
  27. Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
  28. Swarm: inactive
  29. Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
  30. Default Runtime: runc
  31. Init Binary: docker-init
  32. containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
  33. runc version: v1.0.3-0-gf46b6ba
  34. init version: de40ad0
  35. Security Options:
  36. seccomp
  37. Profile: default
  38. Kernel Version: 3.10.0-957.el7.x86_64
  39. Operating System: CentOS Linux 7 (Core)
  40. OSType: linux
  41. Architecture: x86_64
  42. CPUs: 8
  43. Total Memory: 3.84GiB
  44. Name: template
  45. ID: M5UO:W4I4:AUK2:T55U:GV3M:TJA6:CHBU:ZSJR:KHFV:MZ6Q:2535:GL6B
  46. Docker Root Dir: /var/lib/docker
  47. Debug Mode: false
  48. Registry: https://index.docker.io/v1/
  49. Labels:
  50. Experimental: false
  51. Insecure Registries:
  52. 127.0.0.0/8
  53. Registry Mirrors:
  54. https://b7j3uwrc.mirror.aliyuncs.com/
  55. Live Restore Enabled: false
  56. [root@template ~]#

这里可以看到Storage Driver: overlay2,联合文件系统UFS的实现之一就是Overlay

运行监控

  1. [root@template ~]# docker stats
  2. CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
  3. d91aa5eac508 blissful_darwin 0.00% 5.332MiB / 3.84GiB 0.14% 656B / 0B 0B / 14.3kB 9

磁盘占用

  1. [root@template ~]# cd /var/lib/docker/
  2. [root@template docker]# ls
  3. buildkit containers image network overlay2 plugins runtimes swarm tmp trust volumes
  4. [root@template docker]# du -sh *
  5. 76K buildkit
  6. 28K containers
  7. 572K image
  8. 44K network
  9. 292M overlay2
  10. 0 plugins
  11. 0 runtimes
  12. 0 swarm
  13. 0 tmp
  14. 0 trust
  15. 24K volumes
  16. [root@template docker]#
  17. [root@template ~]# docker system df
  18. TYPE TOTAL ACTIVE SIZE RECLAIMABLE
  19. Images 2 1 142.7MB 1.24MB (0%)
  20. Containers 3 1 2.198kB 1.093kB (49%)
  21. Local Volumes 0 0 0B 0B
  22. Build Cache 0 0 0B 0B
  23. [root@template ~]#

磁盘清理

[root@template ~]# docker system prune
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N] y
Deleted Containers:
4828eff744c6d2017b06d074ed97f2ec355aa99eac6b29ffce7ea1c89a147f8f
acb03ef5d9fc8424dacdb5006df2aa00d470fd09ac073130bb33045b21180007

Total reclaimed space: 1.093kB
[root@template ~]#