Docker Learning notes 21:docker settings for connected networks

Source: Internet
Author: User

1. If the Docker host does not need to connect to the extranet via proxy

Docker-related commands, such as Docker search, or the Docker container's network-related operations, do not require special settings.

2, when the Docker host through the proxy to connect to the external network, the use of service mode to start the daemon

If the Docker daemon is started by service (sudo start Docker)

Error when we execute a Docker search Ubuntu command
Error response from Daemon:get https://index.docker.io/v1/search?q=ubuntu:dial tcp:lookup Index.docker.io on 127.0.1.1 : 53:read UDP 127.0.1.1:53:i/o Timeout

And the container that starts up at this point cannot connect to the outer network in the container.

It needs to be done by Setup.

3, when the Docker host through the proxy to connect to the external network, let the Docker daemon can connect the external network, non-service startup mode

Start the Docker daemon in the following way

sudo http_proxy=http://proxy address: Port Docker daemon

This is done when you execute a Docker search Ubuntu command. Note that this does not require the Docker host to set its own proxy Internet access (that is, the Docker process does not take advantage of the host settings of the proxy).

But the normal start of the container, in the container also can not connect the external network.

4, when the Docker host through the agent to connect the external network, the use of service mode to start

You can modify the/etc/default/docker configuration file

# If You need Docker to use an HTTP proxy, it can also is specified here.
#export http_proxy= "http://127.0.0.1:3128/"
Export http_proxy= "/HTTP proxy address: port"

This uses the Sudo start Docker mode to start the daemon

This is done when you execute a Docker search Ubuntu command.

Note that this does not require the Docker host to set its own proxy Internet access (that is, the Docker process does not take advantage of the host settings of the proxy).

But the normal start of the container, in the container also can not connect the external network.

5, how to let the container through the agent online

The container itself is a lightweight Linux system that allows the host to surf the internet as well. The container is connected to the Internet and has no connection to the Docker daemon.

Method One: Temporary networking

Set TEMP environment variable on Shell interface: Export http_proxy= "http://proxy IP address port"

such as: Export http_proxy= "http://10.41.70.8:80"

Once the correct environment variable http_proxy is set, the container will be able to surf the internet normally.

Because it is temporary, when the shell is closed, the environment variable is gone.

Method Two: Modify the . bashrc file in the home directory, add two rows

Http_proxy=http://yourproxyaddress:proxyport
Export Http_proxy

is to persist the environment variable http_proxy, but only valid for that user login.

Note: The container settings agent is not related to the Docker host Setup agent and the Docker Daemon Settings agent, which means that the container only uses its own proxy information to surf the Internet.

Docker Learning notes 21:docker settings for connected networks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.