Setting up Docker proxy under CentOS 7 (environment variable configuration of Systemd service under Linux)

Setting up Docker proxy under CentOS 7 (environment variable configuration of Systemd service under Linux)

The Docker daemon uses HTTP_PROXY , HTTPS_PROXY , and NO_PROXY environment variables to configure the behavior of the HTTP or HTTPS proxy in its startup environment. These environment variables cannot be configured using the daemon.json file.

This example overrides the default docker.service file.

In the setup, you need to add this configuration in the Docker systemd service file

If you use an HTTP proxy server, a systemd plugin directory will be created for the docker service:

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

Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf and add HTTP_PROXY environment variable:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

Alternatively, if you use an HTTPS proxy server, create another file called /etc/systemd/system/docker.service.d/https-proxy.conf and add HTTPS_PROXY environment variable:

[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"

When configuring non-proxy addresses for Docker, you can specify them through the NO_PROXY environment variable, such as the configuration of an HTTP proxy server:

[Service]    
Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Or, HTTPS proxy server configuration:

[Service]    
Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Re-read the service configuration file:

systemctl daemon-reload

Restart Docker:

systemctl restart docker

Verify that the configuration was loaded:

systemctl show --property=Environment docker

refer to:

https://docs.docker.com/config/daemon/systemd/

The above is the details of setting up Docker proxy under CentOS 7 (environment variable configuration of Systemd service under Linux). For more information about Docker configuration of systemd service, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed explanation of the solution to the error of using systemctl to start the service in docker
  • Use of docker system command set

<<:  Examples of new selectors in CSS3

>>:  Several things to note when making a web page

Recommend

Vue uses mockjs to generate simulated data case details

Table of contents Install mockjs in your project ...

Basic installation process of mysql5.7.19 under winx64 (details)

1. Download https://dev.mysql.com/downloads/mysql...

vue-cropper component realizes image cutting and uploading

This article shares the specific code of the vue-...

How to detect if the current browser is a headless browser with JavaScript

Table of contents What is a headless browser? Why...

How a select statement is executed in MySQL

Table of contents 1. Analyzing MySQL from a macro...

Linux directory switching implementation code example

Switching files is a common operation in Linux. W...

How to optimize MySQL index function based on Explain keyword

EXPLAIN shows how MySQL uses indexes to process s...

About the usage and precautions of promise in javascript (recommended)

1. Promise description Promise is a standard buil...

el-table in vue realizes automatic ceiling effect (supports fixed)

Table of contents Preface Implementation ideas Ef...

Detailed steps to download Tomcat and put it on Linux

If you have just come into contact with Linux, th...

Docker installation Nginx tutorial implementation illustration

Let’s install Nginx and try it out. Please note t...

The HTML 5 draft did not become a formal standard

<br />Yesterday I saw at W3C that the new HT...

HTML weight loss Streamline HTML tags to create web pages

HTML 4 HTML (not XHTML), MIME type is text/html, ...