gpt4 book ai didi

docker: error during connect: 在 Windows 上的默认守护程序配置中,docker 客户端必须以提升的权限运行才能连接

转载 作者:行者123 更新时间:2023-12-04 12:15:48 24 4
gpt4 key购买 nike

我正在尝试在 Windows Server 2019 上以进程隔离模式运行 Docker(Docker 桌面在此处不起作用,我的 VPS 不支持 Hyper-V)。
我在 PowerShell 中运行它(都在管理员模式下)docker run -it --isolation=process mcr.microsoft.com/windows/servercore:ltsc2019 cmd.exe /c ping 127.0.0.1 -t然后我得到错误:

docker: error during connect: In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/create: open //./pipe/docker_engine: The system cannot find the file specified.See 'docker run --help'.


我运行命令 & 'C:\Program Files\Docker\DockerCli.exe' -SwitchDaemon ,正如这里的建议: Docker cannot start on Windows
然而, DockerCli.exe在干净的 Docker 安装中不存在:
enter image description here
suggested here我尝试复制文件 DockerCli.exe从我本地的 Windows 10 Docker 桌面安装并重新运行,但随后我得到:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Docker.Core, Version=3.0.0.50646, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.at Docker.Cli.MainBackendCli.Run(IReadOnlyCollection`1 args)at Docker.Cli.MainBackendCli.Main(String[] args)


无论如何,从 Docker 桌面复制文件感觉不是正确的方法。
然后我跑了 dockerd在 PowerShell 中,因为这是该文件夹中唯一的其他可执行文件:
enter image description here
由于我是新手,我不确定我是否刚刚启动了一个容器,如果是,那是哪个,我只看到 start. ,但不知道它来自哪里或我如何配置它。
更新 1
根据 Peter Wishart 的建议,我尝试了 uninstall-Package -Name docker ,但后来我得到
uninstall-Package : No package found for 'docker'. At line:1 char:1
+ uninstall-Package -Name docker
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package]
, Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
这是我尝试过的完整代码:
PS C:\Users\Administrator> uninstall-Package -Name docker
uninstall-Package : No package found for 'docker'.
At line:1 char:1
+ uninstall-Package -Name docker
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package]
, Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

PS C:\Users\Administrator> docker

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default
"C:\\Users\\Administrator\\.docker")
-c, --context string Name of the context to use to connect to the
daemon (overrides DOCKER_HOST env var and
default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level
("debug"|"info"|"warn"|"error"|"fatal")
(default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default
"C:\\Users\\Administrator\\.docker\\ca.pem")
--tlscert string Path to TLS certificate file (default
"C:\\Users\\Administrator\\.docker\\cert.pem")
--tlskey string Path to TLS key file (default
"C:\\Users\\Administrator\\.docker\\key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit

Management Commands:
app* Docker Application (Docker Inc., v0.8.0)
builder Manage builds
cluster* Manage Mirantis Container Cloud clusters (Mirantis Inc., v1.9.0)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
registry* Manage Docker registries (Docker Inc., 0.1.0)
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes

Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/
PS C:\Users\Administrator> Get-PackageProvider -ListAvailable

Name Version DynamicOptions
---- ------- --------------
DockerMsftProvider 1.0.0.8 Update
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 2.8.5.208 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent


PS C:\Users\Administrator> Get-Package -Name Docker -ProviderName DockerMsftProvider

Name Version Source ProviderName
---- ------- ------ ------------
docker 20.10.0 DockerDefault DockerMsftProvider


PS C:\Users\Administrator> Install-Package -Name docker -ProviderName DockerMsftProvider

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'DockerDefault'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS C:\Users\Administrator> Install-Package -Name docker -ProviderName DockerMsftProvider

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'DockerDefault'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Users\Administrator> uninstall-Package -Name docker
WARNING: Docker Service is not available.
uninstall-Package : The property 'Status' cannot be found on this object. Verify that the property exists.
At line:1 char:1
+ uninstall-Package -Name docker
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package],
Exception
+ FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

PS C:\Users\Administrator>

最佳答案

docker 时,错误消息提到的管道访问是一个(可能无关的)问题。客户端由非管理员用户运行(见 here)。
我认为最可能的解释是 docker 服务启动失败。
当你跑 dockerd您实际上是在启动守护程序的一个实例 - 以及行 API listen on //./pipe/docker_engine意味着系统服务之前没有启动 - 因为您启动的实例可以创建管道。
如果停止运行 dockerd实例并运行:

 Get-Service docker | Restart-Service
Get-WinEvent -logname application | where ProviderName -eq docker | sort TimeCreated
您应该能够将日志输出与手动启动 dockerd 进行比较。 ,并查看是否有任何错误阻止服务启动。
如果事件日志记录 API listen on //./pipe/docker_engine然后 Get-Service docker应该将服务显示为正在运行,而您的 docker命令应该没问题。
[编辑]
看起来 docker 的卸载失败了,因为该服务不存在。
但是,除了服务安装外,安装成功。
您可以使用 &'C:\Program Files\Docker\dockerd.exe' --register-service 重新注册该服务
如果 VPS 提供商以某种方式阻止服务注册,这可能会失败?
另一种选择是使用 &'C:\Program Files\Docker\dockerd.exe' --run-service 在一个 shell 中以交互方式运行 docker ,并在另一个 shell 中运行您的 docker 命令。

关于docker: error during connect: 在 Windows 上的默认守护程序配置中,docker 客户端必须以提升的权限运行才能连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67160140/

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