How to Run and Debug Python Inside Docker Containers Using VSCode

preview_player
Показать описание
You don't need to have Python installed on your system in order to run it. Replace Python with almost any other language and keep your computer free from all the things you need to have installed in order to start developing software!
Version collisions are in the past. Create a docker image for each of your projects that you're working on and you will not have to spend hours or days fixing a local environment because you upgraded a package that broke everything.
In this video, I will show you a couple of ways to run Python in a Docker container, and in the end, we will set up VSCode (Visual Studio Code), so you could run and debug your code inside a container without leaving VSCode!

Timeline:
0:00 Why do you want to run code inside a container
0:45 How to run Python in Docker using an interactive terminal
3:00 Create a Docker file to create an image and run your Python code using docker commands
6:10 How to connect Visual Studio Code to a Docker container to run Python code

#SoftwareEngineering #Python #Docker
-------------------------------------------------------------------------------------
📰 *Sign up for my newsletter*

🖥️ *Free Courses to Learn Programming*

🛒 *Products I recommend*

*Connect with me*

#codevev

*Connect with me*

#codevev
Рекомендации по теме
Комментарии
Автор

Thanks, Evgeny for the demo! this is what I was looking for.

mahmoudelzouka
Автор

Thanks for the this Evgeny...this was very simple, short and great help.

TechWazza
Автор

Thanks for the run through, just what I was looking for!

bluesdog
Автор

Awesome Video. Im busy with a project to use Python Data Science tools inside docker, but the tools then control metatrader inside wine. So I can have many algorithms running at once. I like the fact that I can debug line by line the Python code as it controls metatrader

farmingbyfaith
Автор

Thanks mate, really appreciate it <3

ahmedshawky
Автор

Hey! Awesome video!
Just a quick question, when I reach the part after I click "Reopen in Container" ... I'm not getting the option to open "From Dockerfile" (7:22 in your video), I get a list of configuration template. Do you know why maybe?

chennahoom
Автор

This is nice, thank you, I just wonder if it could somehow work with K8s, so when your container dies, VS Code still works (as container would just simply restart) ... Also would be great to see version control integrated into this.

alchemication
Автор

Thanks. I couldn't find the 'Remote - Containers' extension in VS Code but I found something called 'Dev Containers' by Microsoft which sounds like the same thing. Has the name changed maybe?

basicmachines
Автор

Nice explanation. Thanks . Do you some some video to map network drive in docker container?

ammadkhan
Автор

How do we handle venv and requirements.txt. It would be great if you can cover that

devashishnigam
Автор

Thanks! Could you clarify if the VSCode actually created the container itself or connected to an existing container? @7:16. It looks like VSCode created a container to me, because it didn't ask for container name or id.

davidvc
Автор

after running build command getting below error:
failed to compute cache key: "/main.py" not found: not found

pranitpawar
Автор

Hi there! How could I remote debugging on docker container?

sergeyasdf
Автор

And does it work for framesworks like fastAPI, Flask and Django?

flvr
Автор

Hej Thx Evgeny! But could you explain the next steps on e.g. launch.json and how to configure properly? I have my problems there ... Cheers

christiangunther
Автор

uou manually installed python extension in the container, i wonder if its possible docker file to also do that ?

emanueol
Автор

Hi when I click on the icon in the lower left corner and then click on any option in the list I get the message that current user does not have permission to run docker (I wanted to attach to the running container). Does anyone know how to solve this problem?

damircicic
Автор

would you add a video for docker compose?

MandMatt
Автор

I appreciate your explanations. Very clear and the step by step procedure is very nice. However I don't manage to do the last part. I get and error reopening the project in the container :
[7105 ms] Start: Check Docker is running
[7105 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[7177 ms] Server API version: 1.41
[7178 ms] Start: Run in Host: docker volume ls -q
[7225 ms] Host server: Error: spawn docker ENOENT
at ChildProcess._handle.onexit
at onErrorNT
at
[7270 ms] Host server: (node:11049) Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
[7274 ms] Error: spawn docker ENOENT
at ChildProcess._handle.onexit
at onErrorNT
at

The only difference with you is that I did the first part already in a remote access, in SSH. However "reopen in container" is supposed to work. Any idea, welcome. :-)

UpToTheSkyAgain
Автор

Unfortunatly there is no Remote - Containers extension on my VS code :(

brunaguterres