13

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.

I am able to run containers but how I connect to a docker with ssh?

docker-machine ls does not show my docker host.

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 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

veben
  • 19,637
  • 14
  • 60
  • 80
Stan B
  • 303
  • 1
  • 3
  • 12
  • Hi @Stan B! What's your specific use case? That is, what are you trying to do by connecting via SSH? There may be another way to do what you want to. Happy to help, just need a little more info :) Cheers, – Myles Keating Jun 05 '17 at 18:33
  • I am learning docker internals. I want to see processes running in containers and find their correlated processes that runs on hosting machine. I want to access /var/lib/docker/aufs to see images and containers file system. I have two environments. One at home with VMs and I success to do everything, docker-machine shows default machine and I can connect to it with ssh. The second is at work with docker engine installed directly on windows with hyper-v. docker command works, but how can I access engine internals like files and processes? – Stan B Jun 05 '17 at 19:54
  • I think the thread @nhol linked is your best bet. In particular, the answer over there from Ailurarctos seems sound to me. If you have more questions, maybe bump the topic over there? – Myles Keating Jun 09 '17 at 18:38

2 Answers2

13

Run this:

docker run -it --rm --privileged --pid=host justincormack/nsenter1

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.

Reference: https://www.bretfisher.com/getting-a-shell-in-the-docker-for-windows-vm/

Basil Musa
  • 8,198
  • 6
  • 64
  • 63
6

As far as I know you can't connect to the docker VM using SSH and you cannot connect to the console/terminal using Hyper-V Manager either. https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/17

NHol
  • 2,045
  • 14
  • 28
  • I have another machine with docker installed as VM inside VirtualBox. And of course I can connect to it with ssh. When you install docker for windows on machine with already installed VirtualBox and Hyper-V disabled it creates VM in virtualbox called default (boot2docker image). And you can connect to it with ssh like to regular linux VM. – Stan B Jun 05 '17 at 16:24
  • 3
    Yes, but your question states it does not use virtualbox – NHol Jun 06 '17 at 14:07