Is it possible to ssh to the xhyve machine?

I’ve got a process eating all my resources, it’d be helpful to finding it if I could run ps fax on the host VM.

Hi not sure about ssh, but you can enter the xhyve based vm with the
following command;

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

note: I have tried to setup alternative ‘escape’ sequences to exit out of
the vm but I am
having trouble doing so.

I use CTRL+A CTRL+\ followed by “y” to exit the vm and the screen session.

Hi, Thanks for the information.

I use:

docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh

to enter the docker VM on my Mac.

Once in the VM, you can use tools like ‘top’ to watch the processes running in the VM. The VM is a stripped down version of Alpine Linux so you can even install any debugging tools you want using the Alpine package manager.

7 Likes

I build a minimize nsenter image, it’s only 582kB.

docker run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n sh

4 Likes

I use halt to shutdown the xhyve vm. Docker stops and restarts by itslef

I made a Sysdig image to introspect that kind of issue :

It’s awesome ! Thanks a lot !

1 Like

Thanks this wordked for me!!

just to add to detach use ‘ctrl-a’ ‘d’

This leaves a screen session behind, and if you create a new one screen starts to misbehave by losing characters, probably a flow control problem?

Anyway, Ctrl-A Ctrl-\ y works better. What works even better is @walkerlee’s solution.

In some recent release of Docker the location seems to have changed. It’s now:

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

I realize I’m years late to this. I ran this command and it worked but I have no idea why. Can you explain this command to me?

I don’t seem to have any PIDs named “host” on my Mac. Why do I need a debian container to run to get into the Docker for Mac VM?

--pid host

In certain cases you want your container to share the host’s process namespace, basically allowing processes within the container to see all of the processes on the system. For example, you could build a container with debugging tools like strace or gdb, but want to use these tools when debugging processes within the container.
1 Like

As of today, May 18-2020, on docker version 19.03.8, the step you have mentioned works as it is.