参数 作用
—graph DOCKER_ROOT_DIR 指定docker产生数据存放的目录
—registry-mirror URL 指定官方registry的镜像站点
—insecure-registry URL 指定不安全的私有仓库 URL
-H tcp://URL 指定运行远程控制的ip地址和端口

systemd 服务单元文件

如果是通过包管理工具安装的docker,那么也是自动注册到 systemd 服务单元里去了(/lib/systemd/system/docker.service),可以在其中修改启动参数,配置 docker daemon 的运行方式

配置文件

/etc/docker/daemon.json
常用配置,如果没有安装 nvidia-docker2, 下面 runtimes 部门可以去掉

  1. {
  2. "log-driver": "json-file",
  3. "log-opts": {
  4. "max-file": "1",
  5. "max-size": "10m"
  6. },
  7. "insecure-registries": ["registry.local:5000"],
  8. "registry-mirrors": [
  9. "https://registry.docker-cn.com",
  10. "https://4f9bmk46.mirror.aliyuncs.com"
  11. ],
  12. "node-generic-resources": ["NVIDIA-GPU=GPU-f0c6eea"],
  13. "default-runtime": "nvidia",
  14. "runtimes": {
  15. "nvidia": {
  16. "path": "nvidia-container-runtime",
  17. "runtimeArgs": []
  18. }
  19. }
  20. }

全部配置的参考

Linux

  1. {
  2. "authorization-plugins": [],
  3. "data-root": "",
  4. "dns": [],
  5. "dns-opts": [],
  6. "dns-search": [],
  7. "exec-opts": [],
  8. "exec-root": "",
  9. "experimental": false,
  10. "features": {},
  11. "storage-driver": "",
  12. "storage-opts": [],
  13. "labels": [],
  14. "live-restore": true,
  15. "log-driver": "",
  16. "log-opts": {},
  17. "mtu": 0,
  18. "pidfile": "",
  19. "cluster-store": "",
  20. "cluster-store-opts": {},
  21. "cluster-advertise": "",
  22. "max-concurrent-downloads": 3,
  23. "max-concurrent-uploads": 5,
  24. "default-shm-size": "64M",
  25. "shutdown-timeout": 15,
  26. "debug": true,
  27. "hosts": [],
  28. "log-level": "",
  29. "tls": true,
  30. "tlsverify": true,
  31. "tlscacert": "",
  32. "tlscert": "",
  33. "tlskey": "",
  34. "swarm-default-advertise-addr": "",
  35. "api-cors-header": "",
  36. "selinux-enabled": false,
  37. "userns-remap": "",
  38. "group": "",
  39. "cgroup-parent": "",
  40. "default-ulimits": {
  41. "nofile": {
  42. "Name": "nofile",
  43. "Hard": 64000,
  44. "Soft": 64000
  45. }
  46. },
  47. "init": false,
  48. "init-path": "/usr/libexec/docker-init",
  49. "ipv6": false,
  50. "iptables": false,
  51. "ip-forward": false,
  52. "ip-masq": false,
  53. "userland-proxy": false,
  54. "userland-proxy-path": "/usr/libexec/docker-proxy",
  55. "ip": "0.0.0.0",
  56. "bridge": "",
  57. "bip": "",
  58. "fixed-cidr": "",
  59. "fixed-cidr-v6": "",
  60. "default-gateway": "",
  61. "default-gateway-v6": "",
  62. "icc": false,
  63. "raw-logs": false,
  64. "allow-nondistributable-artifacts": [],
  65. "registry-mirrors": [],
  66. "seccomp-profile": "",
  67. "insecure-registries": [],
  68. "no-new-privileges": false,
  69. "default-runtime": "runc",
  70. "oom-score-adjust": -500,
  71. "node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"],
  72. "runtimes": {
  73. "cc-runtime": {
  74. "path": "/usr/bin/cc-runtime"
  75. },
  76. "custom": {
  77. "path": "/usr/local/bin/my-runc-replacement",
  78. "runtimeArgs": [
  79. "--debug"
  80. ]
  81. }
  82. },
  83. "default-address-pools":[{"base":"172.80.0.0/16","size":24},
  84. {"base":"172.90.0.0/16","size":24}]
  85. }

Windows

  1. {
  2. "authorization-plugins": [],
  3. "data-root": "",
  4. "dns": [],
  5. "dns-opts": [],
  6. "dns-search": [],
  7. "exec-opts": [],
  8. "experimental": false,
  9. "features":{},
  10. "storage-driver": "",
  11. "storage-opts": [],
  12. "labels": [],
  13. "log-driver": "",
  14. "mtu": 0,
  15. "pidfile": "",
  16. "cluster-store": "",
  17. "cluster-advertise": "",
  18. "max-concurrent-downloads": 3,
  19. "max-concurrent-uploads": 5,
  20. "shutdown-timeout": 15,
  21. "debug": true,
  22. "hosts": [],
  23. "log-level": "",
  24. "tlsverify": true,
  25. "tlscacert": "",
  26. "tlscert": "",
  27. "tlskey": "",
  28. "swarm-default-advertise-addr": "",
  29. "group": "",
  30. "default-ulimits": {},
  31. "bridge": "",
  32. "fixed-cidr": "",
  33. "raw-logs": false,
  34. "allow-nondistributable-artifacts": [],
  35. "registry-mirrors": [],
  36. "insecure-registries": []
  37. }