Debug Flask/FastAPI App in Docker with PyCharm
1. Clone flask project. (Credit: Ernst Haagsman)
➜ mkdir flask
➜ cd flask
➜ git clone https://github.com/ErnstHaagsman/flask-compose.git Cloning into 'flask-compose'...
remote: Enumerating objects: 35, done.
remote: Total 35 (delta 0), reused 0 (delta 0), pack-reused 35 Receiving objects: 100% (35/35), 6.49 KiB | 3.25 MiB/s, done. Resolving deltas: 100% (7/7), done.
2. Open project in Pycharm
3. Check Prerequisites Link
4. Configuring Docker: Link
5. Configuring Docker Compose as a remote interpreter Link
- Click on show All
- Click on + and select Docker Compose and wait while PyCharm starts your Docker-Compose configuration to scan and index
- Select Docker compose and click on OK.
7. Running your application under Docker-Compose Link
- Click on edit configuration,
- Select python Interpreter: Remote Python .... And click on Apply and ok
Before running the project Docker container status:
Run project by clicking on debug icon.
- Put debug points and access, http://localhost:5000
After project is running Docker container status:
Let me know in comment box if you want to know how to Run flask app in Debug mode in docker over ssh session, I will post article on that as well based on users response.
Note: For FastAPI also we can perfomr same step and run app inside docker and in debug mode.
Thank you.
Thanks Laleet,
I have one question, Can I use PyCharm community edition ?
No John,
It’s Professional feature, so you can not use PyCharm community edition.
Thanks.