简体   繁体   English

当 docker 安装在 Z3D9454Z5F8E94B4D5429A 上时,我应该将 docker config.json 文件放在哪里?

[英]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 :我想使用这样的自定义 docker config.json 文件来重新分配分离击键

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

In a "normal" docker world, ie 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. In a "normal" docker world, ie 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.但是,在运行 /snap/bin/docker 时无法识别此文件。 docker just silently ignores it. docker 只是默默地忽略它。

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:如果我尝试在 /var/snap/docker/current/config/ 中找到 daemon.json 旁边的文件,这也会默默地没有注意到任何 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

Ok, after writing this question, I ran across the answer.好的,写完这个问题后,我遇到了答案。 Snap wants this file to go here: Snap 想要这个文件到 go 这里:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM