Skip to content

Instantly share code, notes, and snippets.

@devops-school
Created May 30, 2020 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save devops-school/0ba58867ded685b5db8f10538869db26 to your computer and use it in GitHub Desktop.
Save devops-school/0ba58867ded685b5db8f10538869db26 to your computer and use it in GitHub Desktop.
How to Configure Docker daemon with a configuration file?

Some popular options for daemon.json

The following sample configures the Docker Engine to accept incoming connections on port 2375. All other configuration options will use default values.

{
    "hosts": ["tcp://0.0.0.0:2375"]
}

The following sample configures the Docker daemon to keep images and containers in an alternate path.

{    
    "data-root": "d:\\docker"
}
{    
    "data-root": "/opt/docker"
}

The following sample configures the Docker daemon to only accept secured connections over port 2376.

{
    "hosts": ["tcp://0.0.0.0:2376", "npipe://"],
    "tlsverify": true,
    "tlscacert": "C:\\ProgramData\\docker\\certs.d\\ca.pem",
    "tlscert": "C:\\ProgramData\\docker\\certs.d\\server-cert.pem",
    "tlskey": "C:\\ProgramData\\docker\\certs.d\\server-key.pem",
}

An example of how to manually start the Docker daemon in linux command line

dockerd --debug \
  --tls=true \
  --tlscert=/var/docker/server.pem \
  --tlskey=/var/docker/serverkey.pem \
  --host tcp://192.168.59.3:2376

listen using the default unix socket, and on 2 specific IP addresses on this host. $ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2

Allowed configuration options on Linux:

{
 "authorization-plugins": [],
 "dns": [],
 "dns-opts": [],
 "dns-search": [],
 "exec-opts": [],
 "exec-root": "",
 "experimental": false,
 "storage-driver": "",
 "storage-opts": [],
 "labels": [],
 "live-restore": true,
 "log-driver": "",
 "log-opts": {},
 "mtu": 0,
 "pidfile": "",
 "graph": "",
 "cluster-store": "",
 "cluster-store-opts": {},
 "cluster-advertise": "",
 "max-concurrent-downloads": 3,
 "max-concurrent-uploads": 5,
 "shutdown-timeout": 15,
 "debug": true,
 "hosts": [],
 "log-level": "",
 "tls": true,
 "tlsverify": true,
 "tlscacert": "",
 "tlscert": "",
 "tlskey": "",
 "swarm-default-advertise-addr": "",
 "api-cors-header": "",
 "selinux-enabled": false,
 "userns-remap": "",
 "group": "",
 "cgroup-parent": "",
 "default-ulimits": {},
 "init": false,
 "init-path": "/usr/libexec/docker-init",
 "ipv6": false,
 "iptables": false,
 "ip-forward": false,
 "ip-masq": false,
 "userland-proxy": false,
 "userland-proxy-path": "/usr/libexec/docker-proxy",
 "ip": "0.0.0.0",
 "bridge": "",
 "bip": "",
 "fixed-cidr": "",
 "fixed-cidr-v6": "",
 "default-gateway": "",
 "default-gateway-v6": "",
 "icc": false,
 "raw-logs": false,
 "registry-mirrors": [],
 "seccomp-profile": "",
 "insecure-registries": [],
 "disable-legacy-registry": false,
 "default-runtime": "runc",
 "oom-score-adjust": -500,
 "runtimes": {
  "runc": {
   "path": "runc"
  },
  "custom": {
   "path": "/usr/local/bin/my-runc-replacement",
   "runtimeArgs": [
    "--debug"
   ]
  }
 }
}

Allowed configuration options on Windows:

{
  "authorization-plugins": [],
  "data-root": "",
  "dns": [],
  "dns-opts": [],
  "dns-search": [],
  "exec-opts": [],
  "experimental": false,
  "features":{},
  "storage-driver": "",
  "storage-opts": [],
  "labels": [],
  "log-driver": "",
  "mtu": 0,
  "pidfile": "",
  "cluster-store": "",
  "cluster-advertise": "",
  "max-concurrent-downloads": 3,
  "max-concurrent-uploads": 5,
  "shutdown-timeout": 15,
  "debug": true,
  "hosts": [],
  "log-level": "",
  "tlsverify": true,
  "tlscacert": "",
  "tlscert": "",
  "tlskey": "",
  "swarm-default-advertise-addr": "",
  "group": "",
  "default-ulimits": {},
  "bridge": "",
  "fixed-cidr": "",
  "raw-logs": false,
  "allow-nondistributable-artifacts": [],
  "registry-mirrors": [],
  "insecure-registries": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment