Docker-compose and pdb

前端 未结 3 586
迷失自我
迷失自我 2020-12-12 15:57

I see that I\'m not the first one to ask the question but there was no clear answer to this:

How to use pdb with docker-composer in Python development?

W

相关标签:
3条回答
  • 2020-12-12 16:05

    Try running your web container with the --service-ports option: docker-compose run --service-ports web

    0 讨论(0)
  • 2020-12-12 16:15

    Use the following steps to attach pdb on any python script.

    Step 1. Add the following in your yml file

    stdin_open: true
    tty: true
    

    This will enable interactive mode and will attach stdin. This is equivalent for -it mode.

    Step 2.

    docker attach <generated_containerid>
    

    You'll now get the pdb shell

    0 讨论(0)
  • 2020-12-12 16:18

    Till my experience, docker-compose up command does not provide an interactive shell, but it starts the printing STDOUT to default read-only shell.

    Or if you have specified and mapped logs directory, docker-compose up command will print nothing on the attached shell but it sends output to your mapped logs. So you have to attach the container separately once it is running.

    when you do docker-compose up, make it in detached mode via -d and connect to the container via

    docker exec -it your_container_name bash

    0 讨论(0)
提交回复
热议问题