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

How to set up DOCKER network agent

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you how to set up the DOCKER network agent, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Background

In some laboratory environments, the server does not have the right to connect directly to the external network and needs to be proxied through the network. We usually configure the network agent directly in configuration files such as / etc/environment, / etc/profile, and so on, which is feasible for most operations. However, the docker command does not use these proxies. For example, if you need to download an image from a public network for docker pull, the following error occurs:

$docker pull hello-worldUnable to find p_w_picpath 'hello-world:latest' locallyPulling repository docker.io/library/hello-worlddocker: Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/p_w_picpaths. You may want to check your internet connection or if you are behind a proxy..See 'docker run-- help'. Solution one:

Stop the docker service and manually start docker daemon using port 2375 to listen on all network interfaces.

$systemctl stop docker.service$ nohup docker daemon-H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock &

For more information, please see * https://docs.docker.com/v1.11/engine/reference/commandline/daemon/#daemon-socket-option*

Solution 2:

Edit the configuration file and / etc/sysconfig/docker under Ubuntu / etc/default/docker,CentOS. However, it is already discouraged to configure daemon by modifying these two files. The use of this method is not encouraged.

HTTP_PROXY= "http://[proxy-addr]:[proxy-port]/"HTTPS_PROXY="https://[proxy-addr]:[proxy-port]/"export HTTP_PROXY HTTPS_PROXY solution III:

This method is persistent and will remain in effect after modification. This method overrides the default docker.service file.

1. Create an embedded systemd directory for the docker service

$mkdir-p / etc/systemd/system/docker.service.d

two。 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]/"

3. 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"

4. Update the configuration:

$systemctl daemon-reload

5. Restart the Docker service:

The above $systemctl restart docker is all the contents of the article "how to set up the DOCKER Network Agent". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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