How to debug Docker containers! (Python + VSCode)

preview_player
Показать описание
I recently encountered an issue where a python unit test was passing inside of a container, but failing locally.

In this video I show a few different tips/techniques for debugging code running within a docker container:

1) Modify the container entrypoint and exec into the container
2) Copy files to and from the container for inspection/comparison
3) Set up a remote debugger inside the container and attach to it from the host

I hope you find these helpful as you debug your own containerized applications.

Cheers!

---
Join the Community:

---

Timestamps:
0:00 - Intro
0:57 - Sample test case overview
1:12 - Sample Dockerfile
2:28 - Tip #1 (modify entrypoint)
4:00 - Tip #2 (docker cp)
5:39 - Tip #3 (remote debugger)
7:16 - Configuring debugger in VSCode
8:54 - Closing thoughts

---

Community Size at Time of Posting:
- Subscribers: 225 🎉
- Channel Views: 3715
Рекомендации по теме
Комментарии
Автор

Nice video. I've been exploring docker containers and the extra abstraction makes debugging more awkward. This was super helpful!

datamike
Автор

Wow the remote debugger and attaching it to vs code will really come in handy! And congrats on the 200 subs 🙌🎉

TuomoKankaanpaa
Автор

Thank you man! This is exactly the kind of concept I was playing with these days. Thank you for explaining how to expose that port from docker to local host.

AZIARGROUS
Автор

Thanks for the best and the clearest tutorial on how to debug python into Docker with VSC !

kab
Автор

Great video! I've always found Docker quite intimidating, this was good to watch

thebluechimera
Автор

This is what I was looking for!!! It seemed so hard to find for some reason. Can't wait to see your channel grow. Keep it up!

akozy
Автор

From traversy, thanks, your devops video are awesome.

machinelearningid
Автор

I would like to see a tutorial that describes how to debug python code mapped from outside the docker (using the -v parameter)but running inside a container for which I have only the container (and not the Dockerfile)

eddydewaegeneer
Автор

Who’s here because you saw this dude on brads channel? Thank you for this sir.

kid_kulafu_
Автор

This is really amazing.
I'm having a use case would really appreciate for helping me out. :)

I'm running services in Docker Containers i-e web, db, worker(celery).
Is there any way so that I can add a breakpoint in the Pycharm(code) and it will start the debugger in the containers(specifically celery worker)?

plashless
Автор

Can you suggest any other dependency for debugging else than debugpy?

ShikhaSingh
Автор

I have my dockerfile made and Im using fastapi python but when I run my application via that play button of VSCODE I run into a error called PYTHON PATH IN YOUR DEBUG CONFIGURATION IS INVALID.
please help me with that
..

bqdofoq
Автор

Dear Sid,
do I have to rebuild the docker image every time I modify something in my .py file?
thanks
regards

yuriwolf
Автор

Can we connect VSCODE debugger AUTOMATICALLY to docker container without hitting the play button in VSCODE ?

uncoding_with_raj
Автор

Hi Sid, I've seen your video tutorial on Brads channel. I'm currently a shopify dev, and I want to become a devops engineer. I am hoping to get tips from you or your channel. Thanks!

jansoriano
Автор

That's great. I'm looking for debugging C in docker with VSCode. Please suggest any solution !!!

danh_phuong
Автор

Nice video. Is it possible to debug the code step by step? Especially when its web2py app?

nareshmp