Hello everyone
I spent some time looking for a way to access the docker VM on Ubuntu and found that on macOS you can access the terminal with:
~/Library/Containers/com.docker.docker/Data/debug-shell.sock,
is there a similar method for Ubuntu as well
Depends on why you need it. Usually you should not run a terminal in the virtual machine, unless - as it is usually said - “you know what you are doing”. IT could be useful fo debugging or just learn about how complex Docker Desktop is.
Here is a blogpost made based on my presentation at a Docker Community All Hands
Running a privileged container and using nsenter can always get you a shell in the virtual machine. What you can do with it has changed recently. I discovered that ctr
is not available in the virtual machine anymore, so even though Docker Desktop components run in containerd containers, you can use ctr to handle those containers. That’s why I made this script some days ago.
#!/usr/bin/env bash
set -eu -o pipefail
docker_version="$(docker version --format '{{ .Client.Version }}')"
ctr_inum="$(docker run --rm "docker:$docker_version" stat /usr/local/bin/ctr -c '%i')"
docker run --rm -it --pid host --privileged ubuntu:22.04 \
nsenter --all -t 1 \
sh -c "export PATH=\$PATH:\$(dirname \$(find / -inum $ctr_inum)) && sh"
It is not an optimal solution, I just played with an idea to make ctr available in the shell.
- It get’s th docker client version on the host so you can get a Docker container which includes the docker client and also the ctr command.
- Then it runs the container to get the inode number of the ctr command on the filesystem
- It runs a privileged container and breaks out from the container to get a shell in the VM
- Using the inode number it searches for the same command in the virtual machine and adds the parent folder to the PATH variable.
- Starts an interactive shell
It should work on Linux as well, even if the solution is not completely logical in some aspects. For example it doesn’t use the docker command, yet I used a Docker image based on the Docker version. Which would be fine, but the containerd in the pulled image is not the same version as the one in the virtual machine. It seemed compatible for what I tried and I didn’t care about getting the same containerd version yet.
Thanks Ákos Takács for your valuable help
I’m doing a report on the tradeoffs between using Decker Engine vs Docker Desktop VM in production and for that reason I want to know the properties of qemu’s virtualization and the Guest kernel that docker uses and as well as containers and thanks for the ctr, I tried to mount /run/containerd/containerd.sock in the VM so I can access it using ctr from my host but didn’t know how to do it .
I discovered that I can access the virtual console using: ~/.docker/desktop/console.sock