Debug python code running in a docker compose on a SSH remote development machine

Viewed 55

I run a docker-compose (python) application on a remote machine, which I can access via SSH for remote development with VS Code. I'm running the docker compose application on a Ubuntu 22.04 LTS machine and develop from a Windows 10 notebook. The remote machine has docker desktop 4.11 installed, as well as the Docker Extension Pack for VSC. When I open the folder on the remote machineand start the application, I can see the that the docker images are created and containers are running. But when I try to attach a Visual Studio Code to the running container I get the error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Is there a way to debug the code inside the docker containers?

1 Answers

Seems like the docker engine fo docker desktop is not found by the docker extension of VSC. Docker desktop for Linux is installs the docker engine in unix://home/<user/.docker/desktop/docker.sock and not under the standard docker engine path mentioned in the error messageunix://var/run/docker.sock. See Switch between Docker Desktop and Docker Engine So my solution is to install the Docker Engine instead of Docker Desktop until a fix of VSC or the VSC Docker extension is available. After attaching Visual Studio Code to the running container you can debug the application in the same way as on your do on your own machine.

Related