在Ubuntu上缺少.docker文件夹

7
我按照官方指南在Ubuntu 18.04 x64上安装了docker-ce
根据“以非root用户身份管理Docker”的说明,我尝试修改.docker文件夹的所有权,但出现了“没有这样的文件或目录”的错误。
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
chown: cannot access '/home/eric/.docker': No such file or directory

事实上,我甚至没有一个名为.docker的文件夹:
$ ls ~/.docker
ls: cannot access '/home/eric/.docker': No such file or directory

在之前的步骤中,我已经成功地运行了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/

我做错了什么?


1
不用担心。如果需要,文件夹将被创建。失败的命令只是确保您是文件夹(及其中的文件)的所有者,以防它是由root创建的。 - Henry
1
回应Henry的评论,我也做了同样的教程,但是在我执行https://docs.docker.com/get-started/part2/上的“docker login”命令之前,.docker文件夹并没有被创建。在那之前,我看不到.docker文件夹。 - CAMD_3441
2个回答

8

我遇到了同样的问题。最终在我重新启动我的笔记本电脑(运行Ubuntu 18.04)后才成功。仅仅注销并重新登录是不够的。

在重新启动之前,手动创建.docker文件夹,使用命令mkdir .docker


同样的问题。重启后,我能够在Ubuntu 20.04LTS上运行hello-world示例而不需要SUDO。但我仍然没有.docker目录。看看是否会在docker登录时创建该目录。 - Jay Schroeder
1
退出登录不足以解决问题,需要重新启动。 - gp.
下班后我试了一下,谢谢!重新启动也解决了我的问题(我按照官方步骤并将自己添加到docker组) - PayamB.

6

成功认证Docker镜像仓库,比如Docker Hub执行docker login命令时,将会创建目录.docker(以及文件.docker/config.json)。

(前提是$USERdocker用户组的一部分。)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接