Sometimes there may be in issue you need to debug which only occurs within a Docker container. Usually that involves using pdb or ipdb to set a breakpoint.
However, by default "ipdb.set_trace()" or "breakpoint()" won’t work. Here’s how to get it working.
1. Enable interactive mode by adding "stdin_open" and "tty" the following to your docker-compose.yml. For example:
Now when you run your tests (docker-compose run app_tests) the terminal will stop at your break point.
2. Attach your local to the container.
In another terminal window run "docker attach <container_id>" which will bring up the ipdb interactive session in your terminal.