Sometimes there may be in issue you need to debug which only occurs within a Docker container. However by default ipdb.set_trace()
won’t work. Here’s how to get it working.
Enable interactive mode by adding
and tty the following to your docker-compose.yml. For example:stdin_open
version: "3"
services:
app_tests:
build: .
stdin_open: true
tty: true
command: ./run_my_tests.sh
Now when you run your tests (docker-compose run app_tests)
the terminal will stop at your break point.
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.