Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Docker Compose Interactive Mode for Debugging

Interactive Docker Container for Debugging with Compose

In order for PDB to work in a Docker container, you can use

docker run -it <image_name>

For Docker Compose, add two lines stdin_open: true and tty: true into the service of your docker-compose.yml:

version: '3'

    build: .
    entrypoint: python
    command: runserver
      - .:/app
      - "8000:8000"
      - ./.env.staging
    stdin_open: true  # This
    tty: true # This

Run your docker container as usual: docker-compose -f <docker_compose_filename> up -d

To start an interactive session, run docker attach <container_id>. You can get your container id with docker ps`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.