The Docker daemon configuration files

by | Nov 28, 2020 | Docker

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.

0 Comments

Leave a Reply

Explore Articles That Align With Your Interests

Overprovisioned Host System – A Nightmare

Overprovisioned host systems in virtualized environments often cause performance issues. Steal Time is a reliable indicator for identifying such bottlenecks. This article explains how to monitor Steal Time using top, the impact of high values, and how monitoring tools...

Well documented: Architecture Decision Records

Heard about Architecture Decision Records? Anyone who moves to a new team quickly faces familiar questions. Why did colleagues solve the problem in this way? Did they not see the consequences? The other approach would have offered many advantages. Or did they see...

Why Event-Driven Architecture?

What is event-driven architecture? What are the advantages of event-driven architecture, and when should I use it? What advantages does it offer, and what price do I pay? In the following, we will look at what constitutes an event-driven architecture and how it...

On-Premise? IaaS vs. PaaS vs. SaaS?

What does it mean to run an application in the cloud? What types of clouds are there, and what responsibilities can they take away from me? Or conversely, what does it mean not to go to the cloud? To clarify these questions, we first need to identify the...