Ubuntu 上缺少 .docker 文件夹

Eri*_*c L 2 ubuntu docker

我按照官方指南安装docker-ce在 Ubuntu 18.04 x64 上。

根据Manage Docker as a non-root user 的说明,我尝试修改.docker文件夹的所有权,并收到“没有这样的文件或目录”错误:

$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
chown: cannot access '/home/eric/.docker': No such file or directory
Run Code Online (Sandbox Code Playgroud)

事实上,我什至没有.docker文件夹:

$ ls ~/.docker
ls: cannot access '/home/eric/.docker': No such file or directory
Run Code Online (Sandbox Code Playgroud)

在前面的步骤中,我能够hello-world成功运行容器:

$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

Yee*_*234 8

有同样的问题。在我重新启动笔记本电脑(运行 Ubuntu 18.04)后,它终于对我有用了。注销并重新登录还不够。

不过,在重新启动之前手动创建了该.docker文件夹mkdir .docker


use*_*378 5

当您成功通过 Docker 注册表(例如运行命令的Docker Hub)进行身份验证时,将创建目录.docker(和文件.docker/config.json)。 docker login

(这预设$USER是组的一部分docker。)