How to Configure Docker daemon with a configuration file?

What is docker Daemon?

The Docker daemon is a service that runs on your host operating system.
It currently only runs on Linux because it depends on a number of Linux kernel features, but there are a few ways to run Docker on MacOS and Windows too.

What is daemon.json?

daemon.json is the file name which is being used to Configure Docker daemon. There are two ways to configure the Docker daemon:

  • Use a JSON configuration file. This is the preferred option, since it keeps all configurations in a single place.
  • Use flags when starting dockerd.

The preferred method for configuring the Docker Engine is using a configuration file. You can create this file if it doesn’t already exist. The –config-file flag can be used to specify a non-default location.

Location of docker configuration file

  • Linux – RHEL – The default location of the configuration file on Linux is /etc/docker/daemon.json
  • Linux – Ubuntu – The default location of the configuration file on Linux is /etc/docker/daemon.json
  • Windows – %programdata%\docker\config\daemon.json. The configuration file can be found at ‘C:\ProgramData\Docker\config\daemon.json’.

Some options can be reconfigured when the daemon is running without requiring to restart the process

The list of currently supported options that can be reconfigured is this:

  • debug: it changes the daemon to debug mode when set to true.
  • cluster-store: it reloads the discovery store with the new address.
  • cluster-store-opts: it uses the new options to reload the discovery store.
  • cluster-advertise: it modifies the address advertised after reloading.
  • labels: it replaces the daemon labels with a new set of labels.
  • live-restore: Enables keeping containers alive during daemon downtime.
  • max-concurrent-downloads: it updates the max concurrent downloads for each pull.
  • max-concurrent-uploads: it updates the max concurrent uploads for each push.
  • default-runtime: it updates the runtime to be used if not is specified at container creation. It defaults to “default” which is the runtime shipped with the official docker packages.
  • runtimes: it updates the list of available OCI runtimes that can be used to run containers.
  • authorization-plugin: it specifies the authorization plugins to use.
  • allow-nondistributable-artifacts: Replaces the set of registries to which the daemon will push nondistributable artifacts with a new set of registries.
  • insecure-registries: it replaces the daemon insecure registries with a new set of insecure registries. If some existing insecure registries in daemon’s configuration are not in newly reloaded insecure resgitries, these existing ones will be removed from daemon’s config.
  • registry-mirrors: it replaces the daemon registry mirrors with a new set of registry mirrors. If some existing registry mirrors in daemon’s configuration are not in newly reloaded registry mirrors, these existing ones will be removed from daemon’s config.
  • shutdown-timeout: it replaces the daemon’s existing configuration timeout with a new timeout for shutting down all containers.
  • features: it explicitly enables or disables specific features.
Rajesh Kumar
Total Page Visits: 120 - Today Page Visits: 1