gpt4 book ai didi

windows - 如果将主机添加到daemon.json,则Windows Docker守护程序会崩溃

转载 作者:行者123 更新时间:2023-12-02 19:48:03 25 4
gpt4 key购买 nike

这是我第一次使用docker。请注意,我在带有WSL 2的Windows上使用Docker Desktop。

我使用的是旧版软件,需要连接到docker守护程序以启动新容器。该软件的安装说明说我需要设置DOCKER_OPTS='-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock'。截至目前,我还没有找到在Windows中设置DOCKER_OPTS的方法,但是将其添加到主机应该可以。

我遇到的问题是尝试将主机添加到C:\Users\<User>\.docker\daemon.json文件(或通过ui)时,docker无法启动。我添加到hosts对象中的内容都没关系,只是hosts对象导致docker在启动时崩溃。

据我了解,这似乎是一个已知问题,但是我发现的所有解决方案似乎都没有答案,或者对于Linux而不是Windows。

我试过使用-H命令,该命令看起来没有任何变化。

如何在不使docker崩溃的情况下将主机添加到daemon.json文件,或者至少设置DOCKER_OPTS值?

我在:
Docker版本19.03.8,构建afacb8b
Windows内部版本19041.329
WSL 2

我已经浏览了这些。

DOCKER_OPTS do not work in config file /etc/default/docker

Unable to start docker after configuring hosts in daemon.json

Enable Remote Docker API on Windows Host - Adding daemon.json breaks docker

Change "hosts" / "-h" Docker for Windows in daemon.json

docker 堆栈跟踪:

Docker.Core.DockerException:
Failed to start
at Docker.LinuxkitDaemonStartup.<StartAsync>d__5.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\LinuxkitDaemonStartup.cs:line 59
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.Engines.WSL2.LinuxWSL2Engine.<DoStartAsync>d__23.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\LinuxWSL2Engine.cs:line 149
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.ApiServices.StateMachines.TaskExtensions.<WrapAsyncInCancellationException>d__0.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.ApiServices.StateMachines.EngineStateMachine.<StartAsync>d__14.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\EngineStateMachine.cs:line 72
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Docker.Engines.Engines.<RestartAsync>d__29.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\Engines.cs:line 274

最佳答案

我也遇到了这个问题。我当前的解决方法是转发到docker外部的端口。我在管理员命令提示符下运行此命令:

netsh interface portproxy add v4tov4 listenport=2375 listenaddress=192.168.1.20 connectport=2375 connectaddress=127.0.0.1
重新启动后,它甚至会粘住,您可以通过以下方式检查:
netsh interface portproxy show all
虽然这不能解决docker在编辑主机文件时崩溃的问题,但它允许您将守护程序主机代理到其他端口。

关于windows - 如果将主机添加到daemon.json,则Windows Docker守护程序会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62433679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com