Skip to content

stilesj-uchicago/docker-python-remote-debug

Repository files navigation

Goals

Create a docker container and expose the debug port and remotely attach a debugger to debug unit tests.

Why am I doing this? In some of the architectures I work on python needs to be fully containerized due to conflicts with the underlying system architecture.

Setup

# Initialized a python project and added it to version control
cookiecutter https://github.com/karec/cookiecutter-flask-restful
  • Build the docker image
docker build --tag "${USER}/docker-python-remote-debug:latest" -f ./Dockerfile .
  • Bring up the docker container
docker-compose -f ./docker-compose.yml up
  • exec into the container to start the debug command
docker exec -it docker-python-remote-debug-web-1 bash
  • Override the entrypoint of the Dockerfile in docker-compose
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m pytest -lvx tests/test_user.py
  • Execute vscode's debugger with the configuration in ./vscode/launch.json

About

Example of attaching to a docker container with a debugger in vscode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published