Skip to content

Skeleton of a repo with VS Code integration for Docker, Python, and PTVSD.

License

Notifications You must be signed in to change notification settings

Whitt83/Docker-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python-Docker

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.

Setup

  1. Install VSCode
  2. Install Python 3.7+
  3. Install VSCode Extensions:
  • Docker
  • GitLens (Optional)
  • Python
  1. Install PTVSD: pip3 install ptvsd==4.2.5 --user
  2. (Optional) Install autopep8: pip3 install autopep8 --user

Forking & Customizing

  • 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

Debugging an existing target

  1. Compose your docker container (ctrl+shift+P, Docker Compose) This will take a few moments to run.
  2. Select a debug target from the dropdown in Visual Studio Code, and hit 'Debug'.
  3. 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.
  4. Success!

Adding a new debug target:

  1. Add an entry in tasks.json
  2. Add an entry in launch.json

Troubleshooting

  • 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.

About

Skeleton of a repo with VS Code integration for Docker, Python, and PTVSD.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published