Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tutorial on how to set up a proxy in Docker

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In some experimental environments, the server does not have the permission to connect directly to the Internet and needs to use a network proxy; usually, the network proxy is directly configured in configuration files such as / etc/envrionment, / etc/profile and so on, which is feasible for most operations. However, these proxies cannot be used by the docker command. The most typical scenario is that docker needs to be mirrored from the public network pull.

The following recommends a method that will remain in effect after modification, overwriting the default docker.service file

1. Create an embedded systemd directory for the docker service

Mkdir-p / etc/systemd/system/docker.service.d

2. Set up the proxy

Create the / etc/systemd/system/docker.service.d/http-proxy.conf file and add the HTTP_PROXY environment variable. Where [proxy-addr] and [proxy-port] are changed to the actual proxy address and port respectively:

[Service] Environment= "HTTP_PROXY= http://[proxy-addr]:[proxy-port]/"" HTTPS_PROXY= https://[proxy-addr]:[proxy-port]/"

If there is an internal Docker registries that does not need to be accessed by a proxy, then you need to set the NO_PROXY environment variable:

[Service] Environment= "HTTP_PROXY= http://[proxy-addr]:[proxy-port]/"" HTTPS_PROXY= https://[proxy-addr]:[proxy-port]/"NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

3. Update configuration

Systemctl daemon-reload

4. Restart the Docker service

Systemctl restart docker

5. Confirm that the settings are in effect

$systemctl show-- property=Environment dockerEnvironment=HTTP_PROXY= http://proxy.example.com:80/

6. Quote

Https://docs.docker.com/engine/admin/systemd/#httphttps-proxy

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report