As of 2021 is the dance going, Mac Users get easily to the VM with the documented methods, and hence to the volumes. There's a way Rocky Chen found to get inside the VM in Mac. With this you can actually inspect the famous /var/lib/docker/volumes. Docker run -it -privileged -pid=host debian nsenter -t 1 -m -u -n -i sh. Let examine the method. Docker Desktop is the easiest way to get started with either Swarm or Kubernetes. A swarm is a group of machines that are running Docker and joined into a cluster. After that has happened, you continue to run the Docker commands you’re used to, but now they are executed on a cluster by a swarm manager.
Problem: How can you get a shell to your Docker container using nsenter?
Solution: The tool “nsenter” allows you to enter into Name Spaces. Container Namespaces are not an exception. Let’s see how you can enter Docker Container using nsenter.
nsenter Installation
sudo docker run –rm -v /usr/local/bin:/target jpetazzo/nsenter
nsenter in action
Let’s say that I have a container “myapache2test” running.
Step 1: Get PID of your container.
sudo docker inspect –format=”{{.State.Pid}}” myapache2test
When you execute the above command, you will get PID for the container “myapache2test”. i.e. 27576
Step 2: Use the PID to enter to the container. The command might look like similar to the one mentioned below (using PID in step 1: 27576)
sudo nsenter –target 27576 –mount –uts –ipc –net –pid
Bingo!!! You will get a /bin/bash shell into the container.
Docker For Mac Center Contact
Shortcut: docker-enter
If you really wan to execute above steps in a single command, you can use docker-enter. Here you go..
Let’s say you have to enter your Docker container “myapache2test” running. You can use a command similar to the one below.
kd@DockerTutorials (Sun Jan 18 – 04:30:04) :~$ sudo docker-enter myapache2test
root@02bb749c90be:/#
You got a bash shell inside your running Docker Container. Enjoy!
I hope you enjoyed it!
Docker For Mac Center For Health
Thank you so much for checking it out!
KD
Docker For Mac Center For Learning
References:
https://github.com/jpetazzo/nsenter
http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/
http://blog.dotcloud.com/under-the-hood-linux-kernels-on-dotcloud-part