Docker, Linux, Technical

MobyLinuxVM Root Access

I’ve needed/wanted this a couple times so posting here to make it easier to find. When using Docker for Windows in Linux mode, it creates a Linux VM running in Hyper-V which actually hosts the containers you create. If you ever need to access that VM, here’s a method that works (thanks to Docker Saigon):
#get a privileged container with access to Docker daemon
docker run --privileged -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker alpine sh

#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

#switch to host FS
chroot /host

 

Leave a Reply

Your email address will not be published. Required fields are marked *