I have just started working on python. I want to debug python code that is running in a docker container . Can anyone please suggest me what could be the best way to remotely debug this? I am open to use any of the IDE like pycharm
or VS Code
etc. Thanks in advance.
Note: I'm using Mac OS for the development
One technique that I used to debug from within container was to :
ENTRYPOINT ["/mydir/mycode.py"]
in the Dockerfile docker exec -it <container name> /bin/bash
Other technique could be to expose the remote debugging port on the docker container using docker expose command which will allow pycharm to connect to the code. A similiar approach is discussed here.
Expanding on what piy26 mentioned regarding exposing a remote docker port, I think pudb is very apt for the task. I wrote a github repository with a simple example and step by step instructions you can clone and try out https://github.com/isaacbernat/docker-pudb
There is more info on this other answer: Running pudb inside docker container
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.