Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bulletinmybeard/180229d5798d5598336b4caeb2b17dd2 to your computer and use it in GitHub Desktop.
Save bulletinmybeard/180229d5798d5598336b4caeb2b17dd2 to your computer and use it in GitHub Desktop.
Debug Python apps via "docker-compose.yml" in PyCharm

If you containerize your Python application using docker-compose.yml, you can easily run and debug the application in PyCharm. Before starting, ensure that no related Docker containers or Python apps are running and occupying the (exposed) ports.

  • Open PyCharm
  • Go to: Add New Interpreter
  • Pick: On Docker Compose
  • Pick Server: Docker
  • Pick Configuration files: ./docker-compose.yml
  • Pick Service: name of the service you want to start and debug
  • Set Environment Variables: add some env vars if desired and not covered by the docker-compose.yml or Dockerfile and click next

The docker-compose.yml should now run with up.

New Target: Docker Compose Pick your System Interpreter aka Python version and click on create

To run and debug your app go to Run > Debug ‘<your app name here>’.

Big thanks to Kostas https://github.com/konskarm 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment