Where are the Docker daemon configuration files located? How to restart the Docker daemon after applying changes to the configuration? How to change and activate the Docker configuration? These are frequently asked questions. But changes to the Docker configuration are seldom. In this way, we forget the answers. The daily marmot greets.

Proxy Settings

Most corporate environments use proxy servers to access the internet. Usually, Linux environment variables define proxy specifics. These environment variables are HTTP_PROXY, HTTPS_PROXY, and NO_PROXY. In this way, Docker allows a Daemon specific configuration for these settings. Take a look at the following example!

/etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=proxy.beispiel.de:8080"
Environment="HTTPS_PROXY=proxy.beispiel.de:8080"
Environment="NO_PROXY=beispiel.de,beispiel.com"

The Docker daemon configuration files

The daemon configuration’s customization has many benefits—for example, the storage driver, network settings, or TLS certificates. If you are interested in the Docker IP pools, then take a look at this article. Or read the official docs here. Usually, you find the configuration at /etc/docker/daemon.json. The file contains all persistent settings, and they are boot safe. Alternatively,  you may use the Daemon command line parameters for evaluation purposes.

/etc/docker/daemon.json

{
  "bip": "192.168.200.1/24",
  "insecure-registries" : ["docker-registry-default.beispiel.de:443"],
  "default-address-pools":[
    {"base":"192.168.201.0/20","size":28},
    {"base":"192.168.202.0/20","size":28}
  ]
}

Restarting the Docker daemon

First, you must flush configuration changes by daemon-reload. Then restart the Docker daemon itself. Finally, verify if changes take effect. Here, we see the Docker environment.

Activate Docker configuration changes

shell> systemctl daemon-reload
shell> systemctl restart docker
shell> systemctl show docker --property Environment
Environment=GOTRACEBACK=crash HTTP_PROXY=http://10.10.10.10:8080/ HTTPS_PROXY=http://10.10.10.10:8080/ NO_PROXY= hostname.example.com,172.10.10.10
Alternatively, directly restart the Docker daemon. Use “service docker restart” command wrapper or the “systemctl” command. Nevertheless, both commands do the same job.
shell> systemctl stop containerd
shell> systemctl stop docker.service
shell> systemctl start docker.service
shell> systemctl start containerd

Does the Docker configuration work?

There are no obvious errors in the configuration. In this way, we start a simple container. The Docker “hello-world” images is tiny and my preferred image. As a result, we should see the following output in the console:

docker hello-world

shell> docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Conclusion

First, you need to know where the Docker daemon configuration is located. Second, change the Docker configuration and refer to official docs. And finally, do not forget to restart the Docker services. Otherwise, the changes will not affect.

Interested in more postings?

New: OKD Docker Image is stuck – Operation not possible

Openshift and also OKD Docker image is stuck when loading. A severe bug in the CRI-O engine causes stuck the OKD Docker images in an invalid and unusable state. There are discussions about timeouts while loading the images from the docker registry or too long...

Windows Subsystem for Linux and Minikube

The Windows Subsystem for Linux is the seamless integration of Linux into Windows. Use Windows natively and quickly issue a Linux command. Apply a Linux command to the Windows file system without having to start a virtual machine. As a result, Linux is always...

New: Openshift OKD causes image layer not known problems

The POD fails to start, and referrers to the image layer not known. The "layer not known" issue may affect one or more cluster nodes. In effect, there is a corrupt docker image on the local disk cache. The layer not known problem still exists, even after a node or...

Docker Content Trust

Docker Content Trust feature enables your environment to run only with signed images. In this way, Docker Content Trust ensures that the docker pulls only signed containers from the docker registry. Once enabled, Docker Content Trust is active for all docker pull...

Docker, networks, subnets and IP address pools

Docker uses default address pools to create subnets. For most use cases, the shipped defaults fit. But sometimes they cause conflicts with existing networks or subnets. Overlapping networks may conflict with existing systems. Or a large number of docker networks...

Docker networks and subnets

Docker uses default address pools to create subnets. For most use cases, the shipped docker subnet defaults fit. But sometimes the docker subnets cause conflicts with existing networks or subnets. Overlapping networks may conflict with existing systems. Or a large...

Software containerization with docker reviewed

Docker software containerization reviewed Putting Software into containers seems to be state of the art. But what are the benefits? Are there any drawbacks? Most people have heard about docker technology. And not less have used docker. But we are looking towards more...

Docker process virtualization

Docker is a lightweight framework for virtualizing application processes. Instead of emulating a computer hardware that still needs an operating system to run applications, Docker takes a different approach. Docker is able to pretend an operating system environment to...