一键安装:

curl -fsSL https://get.docker.com | bash -s docker —mirror Aliyun

国内 curl -sSL https://get.daocloud.io/docker | sh

安装问题:
执行命令提示:
image.png
执行:

systemctl daemon-reload systemctl start docker 查看状态 systemctl status docker

image.png

配置:

配置文件: /etc/docker/daemon.json

  1. {
  2. "authorization-plugins": [],
  3. "data-root": "",
  4. #Docker运行时使用的根路径,根路径下的内容稍后介绍,默认/var/lib/docker
  5. "dns": [],
  6. #设定容器DNS的地址,在容器的 /etc/resolv.conf文件中可查看
  7. "dns-opts": [],
  8. #容器 /etc/resolv.conf 文件,其他设置
  9. "dns-search": [],
  10. #设定容器的搜索域,当设定搜索域为 .example.com 时,在搜索一个名为 host 主机时,DNS不仅搜索host,还会搜索host.example.com。注意:如果不设置,Docker 会默认用主机上的 /etc/resolv.conf来配置容器。
  11. "exec-opts": [],
  12. "exec-root": "",
  13. "experimental": false,
  14. "features": {},
  15. "storage-driver": "",
  16. "storage-opts": [],
  17. "labels": [],
  18. #docker主机的标签,很实用的功能,例如定义:–label nodeName=host-121
  19. "live-restore": true,
  20. "log-driver": "",
  21. "log-opts": {},
  22. "mtu": 0,
  23. "pidfile": "",
  24. #Docker守护进程的PID文件
  25. "cluster-store": "",
  26. "cluster-store-opts": {},
  27. "cluster-advertise": "",
  28. "max-concurrent-downloads": 3,
  29. "max-concurrent-uploads": 5,
  30. "default-shm-size": "64M",
  31. "shutdown-timeout": 15,
  32. "debug": true,
  33. #启用debug的模式,启用后,可以看到很多的启动信息。默认false
  34. "hosts": [],
  35. #设置容器hosts
  36. "log-level": "",
  37. "tls": true,
  38. #默认 false, 启动TLS认证开关
  39. "tlscacert": "",
  40. #默认 ~/.docker/ca.pem,通过CA认证过的的certificate文件路径
  41. "tlscert": "",
  42. #默认 ~/.docker/cert.pem TLScertificate文件路径
  43. "tlskey": "",
  44. #默认~/.docker/key.pemTLSkey文件路径
  45. "tlsverify": true,
  46. #默认false,使用TLS并做后台进程与客户端通讯的验证
  47. "tls": true,
  48. "tlsverify": true,
  49. "tlscacert": "",
  50. "tlscert": "",
  51. "tlskey": "",
  52. "swarm-default-advertise-addr": "",
  53. "api-cors-header": "",
  54. "selinux-enabled": false,
  55. #默认 false,启用selinux支持
  56. "userns-remap": "",
  57. "group": "",
  58. #Unix套接字的属组,仅指/var/run/docker.sock
  59. "cgroup-parent": "",
  60. "default-ulimits": {
  61. "nofile": {
  62. "Name": "nofile",
  63. "Hard": 64000,
  64. "Soft": 64000
  65. }
  66. },
  67. "init": false,
  68. "init-path": "/usr/libexec/docker-init",
  69. "ipv6": false,
  70. "iptables": false,
  71. "ip-forward": false,
  72. #默认true, 启用 net.ipv4.ip_forward ,进入容器后使用sysctl -a|grepnet.ipv4.ip_forward查看
  73. "ip-masq": false,
  74. "userland-proxy": false,
  75. "userland-proxy-path": "/usr/libexec/docker-proxy",
  76. "ip": "0.0.0.0",
  77. "bridge": "",
  78. "bip": "",
  79. "fixed-cidr": "",
  80. "fixed-cidr-v6": "",
  81. "default-gateway": "",
  82. "default-gateway-v6": "",
  83. "icc": false,
  84. "raw-logs": false,
  85. "allow-nondistributable-artifacts": [],
  86. "registry-mirrors": [],
  87. #镜像加速的地址,增加后在 docker info中可查看。
  88. "seccomp-profile": "",
  89. "insecure-registries": [],
  90. #配置docker的私库地址
  91. "no-new-privileges": false,
  92. "default-runtime": "runc",
  93. "oom-score-adjust": -500,
  94. "node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"],
  95. "runtimes": {
  96. "cc-runtime": {
  97. "path": "/usr/bin/cc-runtime"
  98. },
  99. "custom": {
  100. "path": "/usr/local/bin/my-runc-replacement",
  101. "runtimeArgs": [
  102. "--debug"
  103. ]
  104. }
  105. },
  106. "default-address-pools":[{"base":"172.80.0.0/16","size":24},
  107. {"base":"172.90.0.0/16","size":24}]
  108. }