Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make pdb work with docker

Tags:

docker

pdb

I am trying to get pdb working with docker

We have just started using docker in development. I run python scripts inside docker

I can attach to a docker container:

 docker exec  -ti 6e2355917804  /bin/bash 

I can tail the output

 docker attach 6e2355917804

I've read this but I'm not using fig.

I can see the code hit the breakpoint but I can't interact with PDB.

Docker version 1.7.1,

like image 633
andy boot Avatar asked Sep 04 '15 17:09

andy boot


2 Answers

In case you are using docker compose, you need to do the following.

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_instance_id>

You'll now get the pdb shell

like image 193
Arun Kumar Nagarajan Avatar answered Sep 22 '22 00:09

Arun Kumar Nagarajan


I wasn't using the -i flag when launching my original docker container. Make sure to use

docker run -it <job>
like image 41
andy boot Avatar answered Sep 21 '22 00:09

andy boot