I clearly don't understand something here. I am trying to run the pdb
debugger interactively w/in a Docker Container.
Here is some code:
Dockerfile:
FROM python:3.6
ENV PROJECT_DIR=/opt/foo
WORKDIR $PROJECT_DIR
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "foo.py"]
foo.py:
def hello_world():
print("hello world")
if __name__ == '__main__':
#import pdb; pdb.set_trace()
hello_world()
If I run docker build -t foo .
and then docker run foo
, it prints out "hello world" as expected.
But if I uncomment out the call to pdb.set_trace()
above and try again, I get the following error:
/opt/foo/foo.py(8)<module>()
-> hello_world()
(Pdb)
Traceback (most recent call last):
File "foo.py", line 8, in <module>
hello_world()
File "foo.py", line 8, in <module>
hello_world()
File "/usr/local/lib/python3.6/bdb.py", line 51, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/local/lib/python3.6/bdb.py", line 70, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
What am I not getting?
edit: BbdQuit raised when debugging python is not a duplicate issue.
My issue, as @soundstripe correctly identified, was not providing interactive access w/in Docker for pdb.