Docker deamon config path under mac os
Asked Answered
K

4

38

I am using docker in Version 1.12.0 (build 10871) on Mac OS (El Capitan 10.11.4) and I want to provide a config file for the docker daemon.

Under Ubuntu you place the config under /etc/default/docker (see docs). Unfortunately, I cannot figure out where to place the config in Mac OS

Any ideas?

Korry answered 5/8, 2016 at 9:34 Comment(1)
Good question. The Docker for Mac VM's disk image is ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2. I haven't found any config outside of it yet...Chronogram
C
61

Docker 19+

Config file is now available in ~/.docker/daemon.json (see Ed's Answer)

Docker EE/CE 17+

Docker for Mac/Windows has added a config editor to the tray icon UI to allow editing of Dockers daemon.json file that will be persisted in the VM.

To access it go to the Docker Icon > Preferences > Daemon > Advanced enter image description here

Original Answer

The Docker for Mac VM is based on Alpine Linux. The init system is based on OpenRC.

You can attach a screen session to the VM's tty (terminal) and poke around

$ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

The docker daemon config is in the usual spot

moby:/etc/docker# ls -l /etc/docker/
total 8
-rw-r--r--    1 root     root            38 Aug  5 11:26 daemon.json
-rw-------    1 root     root           244 Aug  5 11:26 key.json

The /etc/init.d/docker script that manages the startup does not seem very configurable, apart from editing the script.

/host_docker_app in the VM is a mount of the data in ~/Library/Containers/com.docker.docker/Data/ from OSX. This seems like the most likely place to persist custom config but it doesn't look like there is any interface to source/load config or anything at startup from there.

It looks like changes outside of /var or /host_docker_app will not persist over reboots. There was a mechanism to persist some startup config in the old boot2docker VM image but I haven't found anything like it for the new VM.

Chronogram answered 5/8, 2016 at 12:12 Comment(4)
I get an error on restart. Any idea why? I am on Mac OS Sierra. service docker restart * Stopping docker * Starting Docker ... [ ok ] /etc/docker # /lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/openrc/aws/tasks: nonexistent directoryPau
@Pau submit a question with more detail on what you are trying to do and what you have changed.Chronogram
I opened up a screen to the docker tty as suggested above and then cd /etc/docker I modified daemon.json and added {aws_access_key_id=<key> aws_secret_access_key=<secret>} and then restarted docker with service docker restart and I got the error as abovePau
After 3 attempts, the docker restart did not error. However when I try to log my container logs to AWS Cloudwatch using the awslogs driver - docker run --log-driver=awslogs --log-opt awslogs-region=us-east-1 --log-opt awslogs-group=Contexts --log-opt awslogs-stream=receiptCtxt -d -p mycontainer , I get a credentials error - docker: Error response from daemon: Failed to initialize logging driver: NoCredentialProviders: no valid providers in chain. Deprecated. For verbose messaging see aws.Config.CredentialsChainVerboseErrors.Pau
S
39

On recent versions of Docker Desktop for Mac, the files are in ~/.docker.

~/.docker/daemon.json

Custom (ie. self-signed) certificates can be copied into

~/.docker/certs.d/{MyRegistry:port}/client.crt
Solenne answered 26/7, 2019 at 14:0 Comment(0)
A
7

I am using Docker for Mac 1.13.0 on MacOS 10.12 and the daemon settings can be accessed via the Docker app (Preferences -> Daemon -> Advanced).

But if you change this to something wrong, you will render your installation unusable (the daemon will no longer start-up). This happened to me.

I found out that the settings are stored in a Git repository in ~/Library/Containers/com.docker.docker/Data/database where I had to issue a git reset --hard HEAD before I could change anything. After that the daemon settings are available in ~/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/etc/docker/daemon.json.

Edit, commit and restart the Docker app … et voilà … the daemon starts again.

Acey answered 23/2, 2017 at 9:32 Comment(2)
The database directory doesn't exist in version 2.1.0.5Alecto
The config file for recent Docker versions (19+ I believe) can be found here: ~/.docker/daemon.jsonColumbite
K
2

My docker versin is as follow:

Client:
 Version:   17.12.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built: Wed Dec 27 20:03:51 2017
 OS/Arch:   darwin/amd64

Server:
 Engine:
  Version:  17.12.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   c97c6d6
  Built:    Wed Dec 27 20:12:29 2017
  OS/Arch:  linux/amd64
  Experimental: true

On my OSX 10.13.2, the path of daemon.json is /var/config/docker/daemon.json in the VM. You can use this command to attach a screen session to VM's tty:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

In the VM, you can grep dockerd process to get config file path:

ps aux | grep dockerd

/usr/local/bin/dockerd --config-file /var/config/docker/daemon.json --swarm-default-advertise-addr=eth0 --userland-proxy-path /usr/bin/vpnkit-expose-port --storage-driver overlay2
Keegan answered 27/1, 2018 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.