Rate This Document
Findability
Accuracy
Completeness
Readability

Configuring Docker

  1. Create the daemon.json file to configure Docker.
    1
    2
    sudo mkdir -p /etc/docker
    sudo vim /etc/docker/daemon.json
    

    Content of the daemon.json file:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    {
      "registry-mirrors": [
        "https://dockerhub.azk8s.cn",
        "https://docker.mirrors.ustc.edu.cn",
        "http://hub-mirror.c.163.com",
        "https://k8s.gcr.io",
        "https://github-releases.githubusercontent.com",
        "https://ustc-edu-cn.mirror.aliyuncs.com"
      ],
      "insecure-registries": [
        "registry.me:5000",
        "http://docker.mirrors.ustc.edu.cn",
        "https://k8s.gcr.io",
        "https://github-releases.githubusercontent.com",
        "https://registry-1.docker.io"
      ],
      "exec-opts": [
        "native.cgroupdriver=systemd"
      ]
    }
    
  2. Create the http-proxy.conf file to configure the proxy. Skip this step if a proxy has been configured.
    1
    2
    sudo mkdir -p /etc/systemd/system/docker.service.d
    sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf
    

    http-proxy.conf configuration template (ensure that the proxy settings are correct):

    1
    2
    3
    4
    [Service]  
    Environment="HTTP_PROXY=http://proxy.example.com:8080"  
    Environment="HTTPS_PROXY=http://proxy.example.com:8080"  
    Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com"
    
    • Replace proxy.example.com with the actual proxy server address.
    • NO_PROXY indicates the addresses that do not use a proxy.
  3. Restart the Docker service.
    1
    2
    sudo systemctl daemon-reload  
    sudo systemctl restart docker