Getting a Shell in the Docker for Windows Moby VM

Mar 11, 2018

When using Docker for Windows, you're actually using a tiny (custom) LinuxKit Linux running in a special Hyper-V VM. There's so much cool stuff happening, you're meant to forget it's still running on a Linux kernel.

Note this is about the default "Linux Containers" mode. It doesn't work for "Windows Containers" mode.

This is just a container that will have access to the Linux VM so you can do things like ps aux to see daemons running in the VM. It's not a full OS and I rarely have a reason to do this, but I get asked how to do it, so here ya go. Copy/paste from below or star my Gist here.

Easiest option is Justin's (former Docker CTO) repo and image

Just run this from your CLI and it'll drop you in a container with full permissions on the Moby VM. Note this also works on Docker Desktop for Mac and Docker Desktop for Linux.

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

more info: https://github.com/justincormack/nsenter1

Bret's container, AI, and DevOps learnings, in your inbox!

Join my newsletter for weekly-ish updates on content I'm creating: videos, articles, events, courses and more.