This is a skeleton repo that I made for creating new python projects that run inside a Docker container. The goal is to be able to click the 'Debug' button in VSCode and have it kick off your script inside of your Docker container, with full debugging support.
- Install VSCode
- Install Python 3.7+
- Install VSCode Extensions:
- Docker
- GitLens (Optional)
- Python
- Install PTVSD:
pip3 install ptvsd==4.2.5 --user
- (Optional) Install autopep8:
pip3 install autopep8 --user
- Please fork it and use it. Any errors, please submit back to me (or a pull request!)
- Change the name of the project folder to match your project
- Change the container name -- Note, you will need to do a find & replace in tasks.json on the previous container name!!
- Change the Dockerfile to some more intersting container, like tensorflow
- Delete debug_test.py, and put some interesting project in this repo
- Compose your docker container (ctrl+shift+P, Docker Compose) This will take a few moments to run.
- Select a debug target from the dropdown in Visual Studio Code, and hit 'Debug'.
- Wait 5 - 7 seconds for it to time out. Then click 'Debug Anyway' in the popup. If anybody knows how to get around this, please let me know.
- Success!
- Add an entry in tasks.json
- Add an entry in launch.json
- The internet has observed that mismatching versions of PTVSD on your host environment & in the docker container can lead to problems.
- Make sure something else isn't using port 5678, the default port. Worst case, change the port. You will need to update tasks.json and launch.json.