How to use PDB inside a docker container.

  • It’s important to set stdin_open and tty parameters to true on every service that will use PDB.
  • Usually inside docker-compose.yml specified bundles of services like Nginx & Gunicorn, Nginx & uWSGI etc., so you need to set timeout flag for your WSGI server, because if you won’t do it, then you’ll be only limited with 1 minute (mostly default timeout for all WSGI servers) to debug something and after that, a connection will be lost, so we need to increase it for development purposes.
  • ports parameter should be complemented with 4444 or any other available port, you can check unavailable ports by means such command netstat -lntu inside your terminal. Likewise, the first bullet point, on every service that will be using PDB you need to provide a port.
  • telnet 0.0.0.0 4444 — it’s a default case of connection if you don’t use docker-machine and the scheme is next if you do telnet {docker_machine_ip} {provided_port_from_docker_compose.yml}
  • worth to mention, you need to connect when your Python interpreter will reach a breakpoint.
pdb++ preview from GitHub

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store