Docker'WARNING:permission denied'on Ubuntu

使用docker时,我的Ubuntu机器突然开始显示这个警告:

WARNING: open /home/parallels/.dockercfg: permission denied 

我目前的用户在docker组,这是工作正常。 如何解决这个问题,而不是一直使用sudo?

使用sudo运行命令时,除非通过命令行选项另行configuration,否则将以系统的root用户身份运行。 在你的情况下,文件权限设置为只有root用户具有对文件的读写访问权限,即使你的用户属于docker组,也迫使你使用sudo

尝试复制,粘贴并运行以下内容以补救对文件的访问:

 # Change working directory cd /home/parallels && \ # Give the root user and those belonging to the `docker` group read/write access; # revoke all permissions for everyone else sudo chmod u=rw,g=rw,o= .dockercfg && \ # Set the ownership of the file to the `root` user and `docker` group sudo chown root:docker .dockercfg