如何在启动时启动 Docker 守护进程(windows 服务)而无需登录? [英] How to start Docker daemon (windows service) at startup without the need to log-in?

查看:97
本文介绍了如何在启动时启动 Docker 守护进程(windows 服务)而无需登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 Windows Server 2016 Datacenter 机器上安装了 Docker for Windows.

We have Docker for Windows installed on a Windows Server 2016 Datacenter box.

我们将此框用作 docker 容器的构建代理.

We use this box as a build agent for our docker containers.

当我们尝试通过守护程序连接到此框以构建容器时,我们收到一条错误消息,指示守护程序未运行(在帖子末尾).

When we try to connect to this box via the daemon to build a container, we get an error message indicating the daemon is not running (at end of post).

但是,如果我使用我的 AD 帐户登录到此框,守护程序将启动、运行,然后我可以连接并执行我需要做的一切.

However, if I login to this box using my AD Account, the daemon starts, runs, and then I can connect and do everything I need to do.

有没有办法让守护进程在启动时启动而不需要用户登录?该服务似乎只有在用户登录时才会运行.

Is there a way to make daemon start at boot without requiring the user to be logged in? The service only seems to run if a user is logged in.

错误信息:

连接时出错:发布 http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusecpus=&cpusetmems=&cpushares=0&dockerfile=[NameRemovedForPrivacy]&labels=%7B%7D&memory=0&memswap=0&networkmode=default&sessionrm=1&=[keyRemovedForPrivacy]&shmsize=0&t=[serverNameRemovedForPrivacy]&target=&ulimits=null: open//./pipe/docker_engine: 系统找不到指定的文件.在 Windows 上的默认守护程序配置中,必须提升 docker 客户端运行以进行连接.此错误还可能表示 docker 守护程序未运行.

我尝试过的:

  • 经过验证的 Docker 已在 Windows 服务中列出并配置为自动启动.
  • 在 Windows Task Scheduler 中创建条目以执行 dockerexecutablecom.service.docker 在启动时提升特权.
  • Verified Docker was listed in Windows Services and configured to start automatically.
  • Created entries in Windows Task Scheduler to execute docker executable and com.service.docker at boot with eleveated priveleges.

推荐答案

windows server 的最佳解决方案是使用 Task Scheduler 创建任务,在系统启动时运行Docker Desktop"应用程序.

The best solution for windows server is to use Task Scheduler to create task that run "Docker Desktop" app in case of system startup.

要搜索任务计划程序",请单击创建任务...".

to do that search "Task Scheduler", click on "create task...".

在新选项卡上指定任务名称,然后选择无论用户是否登录都运行"单选按钮和以最高权限运行"复选框.在页面末尾选择适当的窗口类型.

on the new tab specify a name for the task and choose "Run whether user is logged on or not" radio button and "Run with highest privilege" checkbox. at the end of page select appropriate windows type.

现在单击触发器选项卡并添加新触发器.在新的触发器页面上选择启动时",然后单击确定".

now click trigger tab and add new trigger. on the new trigger page select "At startup" and click OK.

最后,单击操作选项卡并添加一个新的操作,该操作运行Docker windows"快捷方式,在 Windows 上运行 docker 守护进程.

finally, click on the actions tab and add a new Action that run "Docker windows" shortcut that run docker daemon on windows.

当 docker 启动时,经过 1 分钟,容器启动可能需要一些时间(在我的情况下为 4 分钟),等待几分钟,然后测试您的 docker 是否正在运行.

As docker starting, pass 1 minute and container starting may take a few time (in my case 4 minute) wait a few minutes and then test whether your docker is running.

这篇关于如何在启动时启动 Docker 守护进程(windows 服务)而无需登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆