Replies: 1 comment
-
Switching this over to a discussion. In a Docker-from-Docker arrangement, it can be pretty difficult to make debugging work. Our debug experience relies on using volume mapping to map in some folders to speed up the inner loop, and volume mapping is extraordinarily difficult in Docker-from-Docker. For Python, we map in the debugpy folder. For our compose debug experience, however, we install debugpy with Our docker-compose.debug.yml file looks something like this: version: '3.4'
services:
flasktest:
image: flasktest
build:
context: .
dockerfile: ./Dockerfile
command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 5000"]
ports:
- 5000:5000
- 5678:5678
environment:
- FLASK_APP=app.py That This is paired with a Python attach configuration in launch.json: {
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
}
]
} Can you try out debugging with that compose debug YML--first doing Docker Compose: Up on it--and then the Python attach config? |
Beta Was this translation helpful? Give feedback.
-
VSCode 1.58
Windows 10.0.19042
WSL2 5.10.16
Docker Desktop 3.5.2 (66501)
So this one is a big gordian knot. I'm running a devcontainer as my environment and set it up to work as Docker-From-Docker as prescribed here: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/docker-from-docker-compose. I'm attempting to run the debug for a flask app with mostly default boilerplate configuration. When that happens the docker debug task successfully creates the container, and runs, but the debugger doesn't attach. I can see from checking the container logs that it's just running at the Python prompt and not proceeding from there. There's no output from the debug console, Python output, etc. It's like it just doesn't start.
This works perfectly fine outside of the devcontainer environment. One other wrinkle: when I try to run it in the devcontainer, I can connect to the container with postman and the vscode browser, but I can't seem to get firefox or any other local browser to work. It just hang there trying to load the page forever. Doesn't time out or anything, just loads forever. When I'm outside of the devcontainer everything works perfectly.
Here's my code in it's entirety at a commit I know has this issue: https://github.com/lavahot/kissaas/tree/b14885c0367371cf0a6e8bcce5c613c5ff7b655b
Here's a docker inspect of the devcontainer:
And here's one of the debug container:
Beta Was this translation helpful? Give feedback.
All reactions