7

I prefer pudb for python debugging. I am building python applications that run inside docker container.

Does any one know how to make pudb available inside docker container?

Thank you

DarcliGht
  • 1,399
  • 2
  • 10
  • 14

1 Answers1

5
  • You need to have pudb installed on the Docker container (this may be done adding this line to the Dockerfile: RUN pip install pudb).
  • You need to have the ports where you will connect to pudb open. E.g.

    • For a Dockerfile: add EXPOSE 6900.
    • For docker-compose the syntax is different:

      ports: - "6900:6900"

  • You need to add a line to set_trace where you want the entry point to be in the Python code. E.g. from pudb.remote import set_trace; set_trace(term_size=(160, 40), host='0.0.0.0', port=6900)

  • When the code is running and reaches that point, you can connect into it with a telnet client and use pudb as you normally would to debug. In the case above, from another terminal type telnet 127.0.0.1 6900.

You can find a repository with a full working example here: https://github.com/isaacbernat/docker-pudb

isaacbernat
  • 395
  • 1
  • 5
  • 19
  • do you have any idea how to avoid the welcome/config screen that appears at the beginning? I tried to copy a pudb.cfg into the container, but it seems to be ignored. – ezdazuzena Apr 09 '19 at 12:54