2

I have a Dockerfile containing the lines:

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

I would like to set some breakpoints on libraries installed via requirements in my local IDE. I am wondering how to launch the docker image such that these files are accessible from my local IDE. The relevant modules are located within the image at:

/usr/local/lib/python3.7/site-packages

so, i was thinking of using the line:

docker run \
    -v site_pkgs:/usr/local/lib/python3.7/site-packages
    --entrypoint python3 \
    app-dev

but, this seems to overwrite the containers directory rendering it unable to find the modules it expects. Any guidance in how to perform this type of debugging on a running container would be very helpful. Thank you!

scagnetti
  • 1,435
  • 3
  • 20
  • 38

1 Answers1

1

a) If you just mean to get the python package module code in container, and have test application in your local IDE to call these modules. Then you do not need to run this container, just:

docker cp /usr/local/lib/python3.7/site-packages .

After that, these python module's py files will be in your local(docker host). Then you can use your local IDE to debug them, of course with your own test code.

b) If you mean to use local IDE directly debug the code in container, then VSCode IDE is your choice.

NOTE: you need to use insiders build currently, as it's a pretty new feature also I think is a great feature.

See Developing inside a Container, vscode give you ability to set IDE in your local host machine, but still can let IDE debug the code in container.

atline
  • 28,355
  • 16
  • 77
  • 113
  • Developing inside a container is much more than what I was asking for. I don't think I'll ever develop any other way. My personal machine stays clean and I discover production errors during dev. This is everything. Do you happen to know if this can currently be done using other IDEs (specifically PyCharm)? – scagnetti May 16 '19 at 20:55
  • I not use pycharm, but maybe next https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html can help you? Maybe you can have a look. Also this: https://stackoverflow.com/questions/30878505/pycharm-add-remote-python-interpreter-inside-the-docker – atline May 17 '19 at 01:35