当前位置:   article > 正文

Docker配置代理

docker配置代理

        有时候我们在使用docker下载镜像的时候可能想要配置代理区下载那么本文就给大家分享一下docker怎么配置代理。

        假设你已经有了代理,那就编辑/usr/lib/systemd/system/docker.service

        在[Service]下添加

  1. Environment="HTTP_PROXY=http://127.0.0.1:6666/"
  2. Environment="HTTPS_PROXY=http://127.0.0.1:6666/"
  3. Environment="NO_PROXY=localhost,127.0.0.1"
  4. # HTTP_PROXY和HTTPS_PROXY填写代理地址
  5. # NO_PROXY填写哪些地址不需要走代理
  1. [root@bogon ~]# cat /usr/lib/systemd/system/docker.service
  2. [Unit]
  3. Description=Docker Application Container Engine
  4. Documentation=https://docs.docker.com
  5. After=network-online.target docker.socket firewalld.service containerd.service time-set.target
  6. Wants=network-online.target containerd.service
  7. Requires=docker.socket
  8. [Service]
  9. Type=notify
  10. Environment="HTTP_PROXY=http://127.0.0.1:6666/"
  11. Environment="HTTPS_PROXY=http://127.0.0.1:6666/"
  12. Environment="NO_PROXY=localhost,127.0.0.1"
  13. # the default is not to use systemd for cgroups because the delegate issues still
  14. # exists and systemd currently does not support the cgroup feature set required
  15. # for containers run by docker
  16. ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
  17. ExecReload=/bin/kill -s HUP $MAINPID
  18. TimeoutStartSec=0
  19. RestartSec=2
  20. Restart=always
  21. # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
  22. # Both the old, and new location are accepted by systemd 229 and up, so using the old location
  23. # to make them work for either version of systemd.
  24. StartLimitBurst=3
  25. # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
  26. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
  27. # this option work for either version of systemd.
  28. StartLimitInterval=60s
  29. # Having non-zero Limit*s causes performance problems due to accounting overhead
  30. # in the kernel. We recommend using cgroups to do container-local accounting.
  31. LimitNPROC=infinity
  32. LimitCORE=infinity
  33. # Older systemd versions default to a LimitNOFILE of 1024:1024, which is insufficient for many
  34. # applications including dockerd itself and will be inherited. Raise the hard limit, while
  35. # preserving the soft limit for select(2).
  36. LimitNOFILE=1024:524288
  37. # Comment TasksMax if your systemd version does not support it.
  38. # Only systemd 226 and above support this option.
  39. TasksMax=infinity
  40. # set delegate yes so that systemd does not reset the cgroups of docker containers
  41. Delegate=yes
  42. # kill only the docker process, not all processes in the cgroup
  43. KillMode=process
  44. OOMScoreAdjust=-500
  45. [Install]
  46. WantedBy=multi-user.target

接下来重启服务即可

  1. sudo systemctl daemon-reload
  2. sudo systemctl restart docker

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/728114
推荐阅读
相关标签
  

闽ICP备14008679号