背景说明

daemon.json文件是docker的配置参数文件,默认文件不会自动创建,需要手动创建,docker不管以何种方式启动,默认都会读取这个配置文件,可以使得用户统一管理不同系统下的docker的daemon配置。

版本支持: docker1.3.1以上 文件绝对路径:/etc/docker/daemon.json

解决方案

官网地址

https://docs.docker.com/engine/reference/commandline/dockerd/

  1. [root@vm1 ~]# dockerd --help
  2. Usage: dockerd [OPTIONS]
  3. A self-sufficient runtime for containers.
  4. Options:
  5. --add-runtime runtime Register an additional OCI compatible runtime (default [])
  6. --allow-nondistributable-artifacts list Allow push of nondistributable artifacts to registry
  7. --api-cors-header string Set CORS headers in the Engine API
  8. --authorization-plugin list Authorization plugins to load
  9. --bip string Specify network bridge IP
  10. -b, --bridge string Attach containers to a network bridge
  11. --cgroup-parent string Set parent cgroup for all containers
  12. --config-file string Daemon configuration file (default "/etc/docker/daemon.json")
  13. --containerd string containerd grpc address
  14. --containerd-namespace string Containerd namespace to use (default "moby")
  15. --containerd-plugins-namespace string Containerd namespace to use for plugins (default "plugins.moby")
  16. --cpu-rt-period int Limit the CPU real-time period in microseconds for the parent cgroup for all containers
  17. --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds for the parent cgroup for all containers
  18. --cri-containerd start containerd with cri
  19. --data-root string Root directory of persistent Docker state (default "/var/lib/docker")
  20. -D, --debug Enable debug mode
  21. --default-address-pool pool-options Default address pools for node specific local networks
  22. --default-cgroupns-mode string Default mode for containers cgroup namespace ("host" | "private") (default "host")
  23. --default-gateway ip Container default gateway IPv4 address
  24. --default-gateway-v6 ip Container default gateway IPv6 address
  25. --default-ipc-mode string Default mode for containers ipc ("shareable" | "private") (default "private")
  26. --default-runtime string Default OCI runtime for containers (default "runc")
  27. --default-shm-size bytes Default shm size for containers (default 64MiB)
  28. --default-ulimit ulimit Default ulimits for containers (default [])
  29. --dns list DNS server to use
  30. --dns-opt list DNS options to use
  31. --dns-search list DNS search domains to use
  32. --exec-opt list Runtime execution options
  33. --exec-root string Root directory for execution state files (default "/var/run/docker")
  34. --experimental Enable experimental features
  35. --fixed-cidr string IPv4 subnet for fixed IPs
  36. --fixed-cidr-v6 string IPv6 subnet for fixed IPs
  37. -G, --group string Group for the unix socket (default "docker")
  38. --help Print usage
  39. -H, --host list Daemon socket(s) to connect to
  40. --host-gateway-ip ip IP address that the special 'host-gateway' string in --add-host resolves to. Defaults to the IP address
  41. of the default bridge
  42. --icc Enable inter-container communication (default true)
  43. --init Run an init in the container to forward signals and reap processes
  44. --init-path string Path to the docker-init binary
  45. --insecure-registry list Enable insecure registry communication
  46. --ip ip Default IP when binding container ports (default 0.0.0.0)
  47. --ip-forward Enable net.ipv4.ip_forward (default true)
  48. --ip-masq Enable IP masquerading (default true)
  49. --ip6tables Enable addition of ip6tables rules
  50. --iptables Enable addition of iptables rules (default true)
  51. --ipv6 Enable IPv6 networking
  52. --label list Set key=value labels to the daemon
  53. --live-restore Enable live restore of docker when containers are still running
  54. --log-driver string Default driver for container logs (default "json-file")
  55. -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
  56. --log-opt map Default log driver options for containers (default map[])
  57. --max-concurrent-downloads int Set the max concurrent downloads for each pull (default 3)
  58. --max-concurrent-uploads int Set the max concurrent uploads for each push (default 5)
  59. --max-download-attempts int Set the max download attempts for each pull (default 5)
  60. --metrics-addr string Set default address and port to serve the metrics api on
  61. --mtu int Set the containers network MTU
  62. --network-control-plane-mtu int Network Control plane MTU (default 1500)
  63. --no-new-privileges Set no-new-privileges by default for new containers
  64. --node-generic-resource list Advertise user-defined resource
  65. --oom-score-adjust int Set the oom_score_adj for the daemon
  66. -p, --pidfile string Path to use for daemon PID file (default "/var/run/docker.pid")
  67. --raw-logs Full timestamps without ANSI coloring
  68. --registry-mirror list Preferred Docker registry mirror
  69. --rootless Enable rootless mode; typically used with RootlessKit
  70. --seccomp-profile string Path to seccomp profile
  71. --selinux-enabled Enable selinux support
  72. --shutdown-timeout int Set the default shutdown timeout (default 15)
  73. -s, --storage-driver string Storage driver to use
  74. --storage-opt list Storage driver options
  75. --swarm-default-advertise-addr string Set default address or interface for swarm advertised address
  76. --tls Use TLS; implied by --tlsverify
  77. --tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
  78. --tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
  79. --tlskey string Path to TLS key file (default "/root/.docker/key.pem")
  80. --tlsverify Use TLS and verify the remote
  81. --userland-proxy Use userland proxy for loopback traffic (default true)
  82. --userland-proxy-path string Path to the userland proxy binary
  83. --userns-remap string User/Group setting for user namespaces
  84. -v, --version Print version information and quit
  85. [root@vm1 ~]#

日志配置

log-driver配置容器日志的默认驱动程序(默认为” json-file”)json-file驱动建议配置如下

  1. {
  2. "log-driver": "json-file",
  3. "log-opts": {
  4. "max-size": "10m",
  5. "max-file": "3"
  6. }
  7. }

下载速度

max-concurrent-downloads并行镜像的连接数,用于提高镜像的下载速度(默认为3)