How to connect to docker VM (MobyLinux) from windo

2019-03-08 22:08发布

问题:

Is there away to log into host VM's shell, similarly to how can we easily enter into running containers bash?

docker exec -it bash

I accidentally broke one container's crucial file, so that it couldn't start. Unfortunately, that container stored it's data inside. The result was that whenever I tried to run it, it couldn't start. The only solutions I saw were about navigating to host docker daemon's files. However, I'm running docker VM on windows, and I cannot access the files inside VM (MobyLinuxVM).

I'm using Docker for Windows, version 1.12.3-beta30.1 (8711)

回答1:

Hack your way in

run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff)

docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh

https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/6



回答2:

With e. G. the Git Bash you can use the following command to connect:

winpty docker exec -it [CONTAINER-ID] sh

You can look up the [CONTAINER-ID] with:

docker ps