dockerubuntusnapcraft

Where do I place a docker config.json file when docker is installed as a snap on Ubuntu?


I want to use a custom docker config.json file like this to reassign the detach keystrokes:

{
     "detachKeys": "ctrl-q,ctrl-q"
}

In a "normal" docker world, i.e. one where docker is installed via apt or similar and not snap, I could put this file in $HOME/.docker/config.json and the setting is picked up when I next run the docker command. However, this file is not recognized when running /snap/bin/docker. docker just silently ignores it.

If I try to force it to use this directory, I am denied:

$ docker --config .docker/ run -it ubuntu /bin/bash
WARNING: Error loading config file: .docker/config.json: open .docker/config.json: permission denied

If I try to locate the file alongside daemon.json in /var/snap/docker/current/config/ this also silently fails to notice any config.json:

$ ls -l /var/snap/docker/current/config/
total 8
-rw-r--r-- 1 root root  36 Feb 28 11:28 config.json
-rw-r--r-- 1 root root 200 Feb 28 09:44 daemon.json

$ docker run -it ubuntu /bin/bash

Now, I can force the directory location, but surely there is a better way?

$ docker --config /var/snap/docker/current/config/ run -it ubuntu /bin/bash

Solution

  • Ok, after writing this question, I ran across the answer. Snap wants this file to go here:

    $ ls -l ~/snap/docker/current/.docker/
    total 4
    -rw-r--r-- 1 gclaybur gclaybur 36 Feb 28 12:04 config.json