How to access the VM created by docker's HyperKit?

DockerDocker MachineDocker for-Mac

Docker Problem Overview


Docker for Mac uses a Linux VM created by HyperKit for storing and running containers on Mac.

With Docker Toolbox, I can just open VirtualBox and access the docker-machine VM. But with Docker for Mac, how do I access the VM created by HyperKit?

Docker Solutions


Solution 1 - Docker

Update 2019-01-31, thanks to ru10's update, now there is a better way:

screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

Original Answer:

After a while, I found following way to get a shell of the VM that was created by HyperKit:

Run from terminal:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

You will see an empty screen, then type enter, you will get a login prompt. Login as root and hit enter, you will get a shell (no password), you will gett the shell:

enter image description here

To exit the session, type Ctrl-A k (then y to confirm).

It is a little bit hacky, but it seems to work for now (Sep 2016) (Sep 2017).

Solution 2 - Docker

Mac OS High Sierra Docker version 18.06.0-ce-mac70 (26399)

screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

instead of

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

Solution 3 - Docker

According to this GitHub issue comment by a Docker maintainer, the recommended way to access the VM is through a privileged docker container.

> Try logging into the VM: (I recommend this instead of using screen on the TTY) > > $ docker run -it --privileged --pid=host justincormack/nsenter1

Solution 4 - Docker

In fact, the answer from augurar is the only working as of 2021 as smammy says, the other options are deprecated.

So:

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

was the right answer and worked for me in MacOS Big Sur as of July 2021.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJifeng ZhangView Question on Stackoverflow
Solution 1 - DockerJifeng ZhangView Answer on Stackoverflow
Solution 2 - Dockerru10View Answer on Stackoverflow
Solution 3 - DockeraugurarView Answer on Stackoverflow
Solution 4 - DockerAthalasView Answer on Stackoverflow