Tag Archives: docker-compose

How to use ipdb with docker-compose

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 stdin_open and tty the following to your docker-compose.yml. For example:

version: "3"
    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.