How to debug Docker containers! (Python + VSCode)

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024

ความคิดเห็น • 51

  • @datamike7457
    @datamike7457 4 ปีที่แล้ว +8

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

    • @DevOpsDirective
      @DevOpsDirective  4 ปีที่แล้ว

      Thanks Mike! Relevant to your area of expertise, containers can be a game-changer for eliminating dependency issues for data science work:
      - Have a legacy model that is still living in the past and requires Python 2.7? No problem!
      - Need different versions of TensorFlow various applications you are developing? Sure!
      - Calling out to some 3rd party tool that only runs in Linux? Great!

    • @meigu01
      @meigu01 3 ปีที่แล้ว

      @@DevOpsDirective Hi i got Error: -m: missing , is this correct? ENTRYPOINT ["python","-m","debugpy", "listen", "0.0.0.:5678", "--wait-for-client","-m"]

  • @timaudsley6080
    @timaudsley6080 2 วันที่ผ่านมา

    Thanks, this is exactly what I required!

  • @TuomoKankaanpaa
    @TuomoKankaanpaa 4 ปีที่แล้ว +1

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

    • @DevOpsDirective
      @DevOpsDirective  4 ปีที่แล้ว

      Thanks! -- Yes, it takes a bit of work to have the separate Dockerfile stage, but for debugging complex issues it is really the way to go!

  • @akozy
    @akozy 3 ปีที่แล้ว

    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!

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว

      Well, I'm glad you found your way to my little corner of TH-cam! 😁
      Welcome to the team! 👋

  • @thebluechimera
    @thebluechimera 4 ปีที่แล้ว +1

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

    • @DevOpsDirective
      @DevOpsDirective  4 ปีที่แล้ว +1

      Thanks @Maria!
      It is a bit of a steep learning curve, but once you get used to it, the added confidence that something in production will behave the same way as on your laptop is amazing!

    • @thebluechimera
      @thebluechimera 4 ปีที่แล้ว

      @@DevOpsDirective I know right! Quite an awesome feeling

  • @AZIARGROUS
    @AZIARGROUS 2 ปีที่แล้ว

    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.

  • @kab9996
    @kab9996 3 ปีที่แล้ว

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

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว

      Woot! Thanks @Ka -- your comment makes me smile :)

  • @user-bq4do4fo2q
    @user-bq4do4fo2q 6 หลายเดือนก่อน

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

  • @machinelearningid3931
    @machinelearningid3931 3 ปีที่แล้ว

    From traversy, thanks, your devops video are awesome.

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว

      Welcome aboard @Machine Learning ID! 👋👋👋
      Happy to have you here!

  • @ShikhaSingh04
    @ShikhaSingh04 5 หลายเดือนก่อน

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

  • @plashless3406
    @plashless3406 2 ปีที่แล้ว +1

    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)?

  • @yuriwolf6234
    @yuriwolf6234 7 หลายเดือนก่อน

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

    • @yuriwolf6234
      @yuriwolf6234 7 หลายเดือนก่อน

      just answering myself:
      I got to mount the :/app directory on the container to a path on my local machine where i copy my files
      docker run -v /path/on/local/machine :/app -p 5678:5678 image_id main_python_file

  • @kid_kulafu_1727
    @kid_kulafu_1727 3 ปีที่แล้ว

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

  • @uncoding_with_raj
    @uncoding_with_raj ปีที่แล้ว

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

  • @eddydewaegeneer9514
    @eddydewaegeneer9514 2 ปีที่แล้ว

    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)

  • @user-nu4so7zg8r
    @user-nu4so7zg8r 2 ปีที่แล้ว

    Great video, thanks !

  • @abrahammathewos9917
    @abrahammathewos9917 3 ปีที่แล้ว

    Thank you! you are the best.

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว

      Thank you @Abraham! Comments like this make me want to keep putting out even better videos!

  • @mariacristinaarezzi
    @mariacristinaarezzi ปีที่แล้ว

    I'm happy to meet you

  • @danh_phuong9297
    @danh_phuong9297 2 ปีที่แล้ว

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

    • @DevOpsDirective
      @DevOpsDirective  2 ปีที่แล้ว

      One options would be to have a multi-stage image with an extra Debugger stage in which you install any of your favorite debugging tools. This way you can keep your production image small but have an image to recreate any bugs in that has the necessary tools for debugging

  • @SgtMajorJay
    @SgtMajorJay 3 ปีที่แล้ว

    Your videos are fire

  • @nareshmp1
    @nareshmp1 2 ปีที่แล้ว

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

    • @DevOpsDirective
      @DevOpsDirective  2 ปีที่แล้ว

      Once you have attached the debugging session as shown in the video you should be able to step through to any breakpoints you set!

  • @acavaelnick
    @acavaelnick 2 ปีที่แล้ว

    Great, thanks

  • @jansoriano7451
    @jansoriano7451 3 ปีที่แล้ว

    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!

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว +1

      Hi @Jan - Happy to have you here! Welcome to the team! 👋👋👋

    • @jansoriano7451
      @jansoriano7451 3 ปีที่แล้ว

      @@DevOpsDirective Thanks Sid!

  • @edustreamimg
    @edustreamimg 3 ปีที่แล้ว

    good job buddy!

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว

      Thanks @Eduardo!

    • @edustreamimg
      @edustreamimg 3 ปีที่แล้ว

      @@DevOpsDirective In 6:35 you are creating 3 images?

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว +1

      @@edustreamimg Yeah, here is more info on multi-stage builds docs.docker.com/develop/develop-images/multistage-build/
      By using the --target option when building the Dockerfile I can tell Docker which of the stages I want it to build (docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage)

    • @edustreamimg
      @edustreamimg 3 ปีที่แล้ว

      @@DevOpsDirective Is a good practice not to run debugger in same container? why?

    • @DevOpsDirective
      @DevOpsDirective  3 ปีที่แล้ว +1

      @@edustreamimg There are a number of reasons you wouldn't want to have a debugger running inside your production container. The three that come to mind are:
      1) Simplicity -- Each container should have a singular focus. By adding a debugger, you lose that.
      2) Security -- It's best not to have additional surface area for potential attackers to try and exploit (you would need to open an additional port to access, etc...)
      3) Performance -- having the debugger running is one more thing to take compute cycles away from your application
      TH-cam comments are a bit clunky for technical discussions. I have a discord server if you want to continue the discussion with lots of other smart folks! discord.gg/CQYSqKvqqa

  • @jarorkwong8042
    @jarorkwong8042 3 ปีที่แล้ว

    Volumn up

    • @DevOpsDirective
      @DevOpsDirective  2 ปีที่แล้ว

      Thanks, this was before I had figured out the whole audio recording/editing thing... 😅
      Hopefully my newer videos have better, more consistent audio!