在Windows上使用SSH连接到Docker守护程序 [英] Connect with ssh to docker daemon on Windows
问题描述
我在Windows 10上使用 https://docs.docker.com/docker-for-windows/install/#install-docker-for-windows .它不使用VirtualBox和默认VM来托管Docker.
I installed Docker Desktop for Windows on Windows 10 with https://docs.docker.com/docker-for-windows/install/#install-docker-for-windows. It not uses VirtualBox and default VM to host docker.
我能够运行容器,但是如何使用ssh连接到Docker?
I am able to run containers but how I connect to a docker with ssh?
docker-machine ls
不显示我的Docker主机.
docker-machine ls
does not show my docker host.
试图连接到docker@10.0.75.1,但需要密码.与用于boot2docker VM的tcuser
不匹配:
Tried to connect to docker@10.0.75.1 but it requires password. And tcuser
that used for boot2docker VM not matching:
ssh docker@10.0.75.1无法创建目录'/home/stan/.ssh'.这 无法确定主机"10.0.75.1(10.0.75.1)"的真实性. RSA 关键指纹是....确定要继续连接吗? (是/否)?是无法将主机添加到已知主机列表 (/home/stan/.ssh/known_hosts). docker@10.0.75.1的密码:写 失败:对等连接重置
ssh docker@10.0.75.1 Could not create directory '/home/stan/.ssh'. The authenticity of host '10.0.75.1 (10.0.75.1)' can't be established. RSA key fingerprint is .... Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts (/home/stan/.ssh/known_hosts). docker@10.0.75.1's password: Write failed: Connection reset by peer
推荐答案
运行此命令:
docker run -it --rm --privileged --pid=host justincormack/nsenter1
只需从您的CLI运行此命令,它将把您放到具有以下内容的容器中 Moby VM的完整权限.仅适用于Moby Linux VM(无效) 适用于Windows容器).请注意,这也适用于Mac版Docker.
Just run this from your CLI and it'll drop you in a container with full permissions on the Moby VM. Only works for Moby Linux VM (doesn't work for Windows Containers). Note this also works on Docker for Mac.
参考: https://www.bretfisher.com/在docker-for-windows-vm/
这篇关于在Windows上使用SSH连接到Docker守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!