我可以 运行 Docker 没有管理员权限的 Windows 桌面吗?

Can I run Docker Desktop on Windows without admin privileges?

我知道我需要 安装 Docker 桌面的管理员权限;但是我必须是 运行 的管理员吗? documentation 并没有说我这样做,谷歌搜索也不建议这样做;但是如果我尝试 运行 它作为非特权用户,进程会立即被终止,并且我得到一个事件日志条目说 "Process requires elevated rights to run."

我是 运行ning Windows 10 企业,在公司环境中,我们有非特权帐户。是 Docker Desktop 在这种情况下不可用还是我刚刚安装不正确?

答案似乎是 "no"。我不明白工作中的其他人是如何避免这个问题的;但后来得知他们曾要求获得本地计算机的管理员权限并获得了他们的授权!我才来这里两年半...:|

我没测试过,不过this article好像可以。

TLDR;

问题

The reason for requiring an admin session is that the Docker client in the default configuration uses a named pipe to connect to the Docker engine and that named pipe can only be accessed by administrators

解决方案

To avoid this, you can simple allow your user FullControl access to that named pipe

原作者还提供a powershell tool with sources来帮助执行此管理任务。

我可以从我的 Windows 10 机器上的非管理员帐户 运行 Docker 桌面。我还可以从非提升的命令提示符或 PowerShell 提示符发出 docker 命令。请注意,我的非管理员帐户是本地组 docker-users.

的成员

最初,我是从我的管理员帐户安装它的,一切都按预期进行,但前提是我以管理员身份保持登录。如果我没有以管理员身份登录,我会收到 aboellinger 在他的回答中描述的命名管道错误。

只需从我的非管理员帐户启动 C:\Program Files\Docker\Docker\Docker Desktop.exe 即可解决此问题(等待几秒钟以启动进程)。它甚至没有要求提升权限。

Docker 在设计上是不安全的,如果用户可以 运行 docker 命令而无需管理员权限(即属于 docker 组)这基本上意味着这用户可以逃脱容器并成为主机上的管理员。不知道如何在 Windows 上完成它,但它在 Linux 上“正常工作”。

从 Docker Desktop 2.4 开始(可能更早,我还没有测试过)这是支持的。来自 Windows installation instructions:

If your admin account is different to your user account, you must add the user to the docker-users group. Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Log out and log back in for the changes to take effect.

将我的用户帐户添加到组 docker-users 解决了我的问题。但是,由于我不是 运行 Win10 Pro,因此无法使用 GUI 访问帐户控制。相反,我 运行 PowerShell 作为管理员并将我的用户帐户添加到组 docker-users 那里。

最新版本的 Docker 桌面允许这样做,但用户应该在 docker-users 组中。

如果您使用的是Windows 10 Home 版,那么即使您使用'netplwiz'.

,为普通用户添加多个组也会很痛苦

要向用户添加新组,您可以在 Powershell 中使用以下命令。

运行 powershell admin,然后执行

net localgroup "docker-users" "" /add