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

jQuery plugin to achieve seamless carousel

Seamless carousel is a very common effect, and it...

React implements multi-component value transfer function through conetxt

The effect of this function is similar to vue的pro...

How to delete node_modules and reinstall

Table of contents Step 1: Install node_modules in...

How to implement responsive layout with CSS

Implementing responsive layout with CSS Responsiv...

Several important MySQL variables

There are many MySQL variables, some of which are...

Detailed explanation of the use of grid properties in CSS

Grid layout Attributes added to the parent elemen...

Detailed explanation of MySQL partition table

Preface: Partitioning is a table design pattern. ...

Let IE support CSS3 Media Query to achieve responsive web design

Today's screen resolutions range from as smal...

How to implement parent-child component communication with Vue

Table of contents 1. Relationship between parent ...

Steps to set up Windows Server 2016 AD server (picture and text)

Introduction: AD is the abbreviation of Active Di...

Hbase Getting Started

1. HBase Overview 1.1 What is HBase HBase is a No...