Docker VSCode Python Tutorial // Run your App in a Container

  Рет қаралды 90,987

Christian Lempa

Christian Lempa

Күн бұрын

Docker VSCode Python Tutorial to run your application inside a Docker Container. I will show you how to set up your development environment with VSCode, which extensions you need and how debugging works. #Docker #VSCode #Python
DOCS: github.com/christianlempa/vid...
Install WSL2: docs.microsoft.com/en-us/wind...
Install Docker Desktop: docs.docker.com/docker-for-wi...
WSL2, ZSH, Awesome Terminal!: • Make your WSL or WSL2 ...
Get started with Python: • Best Code Editor for P...
Get started with Docker: • The Difference between...
Get started with DevOps: • Automate your Docker d...
Follow me:
TWITTER: / christianlempa
INSTAGRAM: / christianlempa
DISCORD: / discord
GITHUB: github.com/christianlempa
PATREON: / christianlempa
MY EQUIPMENT: kit.co/christianlempa
Timestamps:
00:00 - Introduction
00:52 - Why we need Linux
01:28 - Install WSL2 on Windows 10
03:26 - Install Docker Desktop on Windows 10
04:07 - Install VSCode Extensions
05:05 - Connect VSCode to WSL2
06:10 - A simple Python App Example
08:02 - Generate Docker Files
09:30 - What are these Docker Files?
14:01 - Build and Run our Docker Image
15:12 - How Debugging works
17:47 - What can you do next?
----
All links with "*" are affiliate links.

Пікірлер: 98
@Sultaneous
@Sultaneous 4 күн бұрын
came across you on Network Chuck. Great stuff, thank-you!
@Youyoyo854
@Youyoyo854 2 жыл бұрын
That's so helpful!!! I'm a total beginner and it really helped me step by step to build my first docker image!! Thank you!
@webjakob
@webjakob 7 ай бұрын
This worked nicely for me. Thank you for a good tutorial. Being able to debug inside a container is a great feature.
@VincentStevenson
@VincentStevenson Жыл бұрын
I kept getting stuck on the debug part inside of the container within VS Code - thank you for being so informative!
@nataliamatteoni
@nataliamatteoni 3 жыл бұрын
"and because I don't have a very good example let's create a very simple application" YES man Tutorials that focus ONLY on what want to learn, just what we need!
@christianlempa
@christianlempa 3 жыл бұрын
Thanks 😁
@diem389
@diem389 Ай бұрын
This is the lecture I were looking for last 7 days! Thanks.
@christianlempa
@christianlempa Ай бұрын
Awesome, glad I could help :)
@sowmyaranjannayak7014
@sowmyaranjannayak7014 Жыл бұрын
Fast and clear, thank you very much.
@PaulPetersVids
@PaulPetersVids 2 жыл бұрын
Thank you keeping the python example simple.
@christianlempa
@christianlempa 2 жыл бұрын
You're welcome!
@dylanr3875
@dylanr3875 2 жыл бұрын
Very informative and just what i was looking for. Thanks & subbed! :)
@christianlempa
@christianlempa 2 жыл бұрын
Thanks mate
@CoderShark
@CoderShark Жыл бұрын
Thank you very for clarifying basic concepts of docker.
@christianlempa
@christianlempa Жыл бұрын
Glad it was helpful!
@saeedrahman8362
@saeedrahman8362 2 жыл бұрын
Thanks , this simplified everything.
@christianlempa
@christianlempa 2 жыл бұрын
Great to hear 😉
@SadhamHussainsree
@SadhamHussainsree 2 жыл бұрын
Excellent excellent content.Thanks for sharing your knowledge.
@christianlempa
@christianlempa 2 жыл бұрын
Thank you so much for the great feedback :)
@iancurtisfan898
@iancurtisfan898 6 ай бұрын
Yo Chris this is lit! Thanks 😎👍
@zaur66
@zaur66 3 жыл бұрын
Really great video. Thank you
@christianlempa
@christianlempa 3 жыл бұрын
Glad you liked it!
@elbezz
@elbezz 7 ай бұрын
Thank you Christian!
@nikkiromero4315
@nikkiromero4315 2 жыл бұрын
Thanks for this video. Very useful
@christianlempa
@christianlempa 2 жыл бұрын
You're welcome
@clintphillips2527
@clintphillips2527 Жыл бұрын
This is great bruh!
@lucychan494
@lucychan494 2 жыл бұрын
I can't Thank you enough ,you just solved my problem
@christianlempa
@christianlempa 2 жыл бұрын
Happy to help
@machinimaaquinix3178
@machinimaaquinix3178 7 ай бұрын
Thanks for this well done video for first steps. You got a new sub! I'd love to have seen a followup video that explains how to update your code in the docker image and install python dependencies as well.
@christianlempa
@christianlempa 7 ай бұрын
Thanks 😊
@lencazero4712
@lencazero4712 10 күн бұрын
@ChristianLempa. Thank you for your tutorials. Could you please share what type of lights do you use for your room background? Thank you.
@Chuukwudi
@Chuukwudi 10 ай бұрын
Excellent video! Thanks! Been looking for this for ages but that is not the reason why I watched this video. I thought there was a way to write a program outside a docker container and run that same code in a linux environment of docker container despite being on windows.
@user-wr4yl7tx3w
@user-wr4yl7tx3w 2 жыл бұрын
yes, would like to learn more about docker image pls
@dr_flunks
@dr_flunks Жыл бұрын
vs code has since changed a few times so this video just serves to compound the annoyance with building on microsoft
@focusmicro
@focusmicro 11 ай бұрын
Interesting , I used ChatGPT today and within 30 mins created images from my scripts, containerized in docker and monitor with portainer if needed. :D Never heard of this VScode before today haha.
@crazybeater8238
@crazybeater8238 10 күн бұрын
Great video, very helpful. Solved alot of the problems I encountered prior. But I have few question regarding VS, why did you run VS in ubuntu(wsl), you can still do the rest while running VS in windows like Docker: workspace ect.. . Also Is it better to allow your container to keep running, for example if you use -jupyter version of images your container will never stop running. though I want to avoid using jupyter, I still wonder if leaving your container running yields different results when debugging?
@apilogicserver
@apilogicserver Жыл бұрын
Hi, Christian.... thanks for this, wish I had seen it when I got started. I was particularly interested in the ability to create containers using VSCode tasks. You might be interested in API Logic Server - it creates executable web app projects from a database, including support for developing in docker, and creating docker containers.
@christianlempa
@christianlempa Жыл бұрын
Thanks I will have a look ;)
@valjhuber
@valjhuber Жыл бұрын
@@christianlempa are you in code spaces beta?
@longrolstral
@longrolstral Жыл бұрын
Great video. I wasn't using VSCode. I had to build the container again without the non-root user because the sqlite3 database I had was read-only.
@christianlempa
@christianlempa Жыл бұрын
Thank you!
@vaha2833
@vaha2833 Жыл бұрын
very good
@christianlempa
@christianlempa Жыл бұрын
Thanks
@dineshr93
@dineshr93 2 жыл бұрын
Thanks for the video.please may I know how to get the different colors for the different indentation like at 16:54
@jowiedog
@jowiedog 2 жыл бұрын
slightly expanded this example in python to output/print to a file. Any ideas how I would be able to save this output file to host machine, rather then container
@matthewcrosby3501
@matthewcrosby3501 10 ай бұрын
Thanks for the tutorial. I wasn't able to run the docker container though as my repository didn't have a name created automatically. it just said . Do you know what I did wrong?
@staaliskander5232
@staaliskander5232 2 жыл бұрын
thank you
@christianlempa
@christianlempa 2 жыл бұрын
You're welcome
@shiblinomani6149
@shiblinomani6149 3 ай бұрын
I need to access my csv file for pyspark task. What do I do to make my local drive accessible?
@kiunthmo
@kiunthmo 2 ай бұрын
How can I set my docker container to an already built one? Can I avoid rebuilding the container each time I run debug?
@TheAbsoluteSir
@TheAbsoluteSir Жыл бұрын
at 14:10 if it is not letting you build, try logging into your docker account by copy and pasting "docker login" in the terminal and then typing in your username and password. Password will be invisible as is normally the case so don't freak out if you cannot see the text.
@jetmirhaxhisefa1811
@jetmirhaxhisefa1811 2 жыл бұрын
Shouldn't you configure the python interpreted somehow to point to the docker container?
@alifnaiech6972
@alifnaiech6972 3 жыл бұрын
Waiting this video, thank you Christian! How about FastAPI ?
@christianlempa
@christianlempa 3 жыл бұрын
Thank you 😊, FastAPI needs to wait a little bit
@chriskeo392
@chriskeo392 Жыл бұрын
Compose video?
@QuintinMassey
@QuintinMassey Жыл бұрын
Is there a way to mount host directories in the docker container? I have been searching for how to do this, but all I have pulled up is how to do it with "devcontainer.json." The process you showed in your video seems different for some reason.
@artabalt4288
@artabalt4288 Жыл бұрын
I have the problem that when I try to add and import a module, say "import numpy as np" it tells me that Pylance is not finding it. Any tips on how to fix that?
@learnwithme395
@learnwithme395 2 жыл бұрын
Hi, can anyone help me, I'm wrote my python code(for desktop app) in pycharm, I want to upload it to Microsoft, what steps should I follow?
@suryaswayoflooking6435
@suryaswayoflooking6435 2 жыл бұрын
How can I do it if I have an input variable in the python script. please let me know. Thanks in prior.
@eranotzap876
@eranotzap876 Жыл бұрын
is there a way to change the code and run again without building the entire container ?
@GQElvie
@GQElvie 2 жыл бұрын
Hello and thank you for posting. I am not very tech savvy, so perhaps you said this but I missed it, but we then have to run python INSIDE Of docker, correct? How do we do that? is there a line(s) in CMD? Thanks
@christianlempa
@christianlempa 2 жыл бұрын
Hey mate, yeah you can run a CMD inside docker that executes the python3 command, just like on the terminal
@maximpobihun5469
@maximpobihun5469 Жыл бұрын
It doesn't create settings.json when I create new python file on vscode
@user-wr4yl7tx3w
@user-wr4yl7tx3w 2 жыл бұрын
Will the files persist when you stop the containers?
@PrasinoXorton
@PrasinoXorton 2 жыл бұрын
Hello Christian. I am now starting to get into docker and I have a question. Aren't 116 MB for running a simple python application too much? I think most of this space is the debian image that we are using to run the python script on. Wouldn't be more space efficient to not have an entire os image to run the script? Like having only the python bin in the container? Is this possible?
@christianlempa
@christianlempa 2 жыл бұрын
There are much more lightweight and smaller images of containers available. Take a look at alpine images f.e.
@Keptains
@Keptains 2 жыл бұрын
Because i was curious aswell: As he stated, alpine is really lightweight in terms of size. To be more specific 5MB
@manuelorellana8863
@manuelorellana8863 Жыл бұрын
Hi, thanks for this info! I have a question though, what if you are using a library like pandas or matplotlib and need the intellisense to autocomplete or easily access the description of methods that are in libraries that get loaded into the image - container but are not installed locally? I know you can attach to a running container, but when you are building a simple app in python the container stops running right after the script finishes. is there anyway to attach to a container that is stopped to get these features? or the only solution is to install the libraries locally? thanks!
@christianlempa
@christianlempa Жыл бұрын
Good question, I haven't really looked into that to be honest.
@manuelorellana8863
@manuelorellana8863 Жыл бұрын
@@christianlempa thanks for the answer, i just came up with installing libraries locally, couldn’t find a way to get that with a stopped container. If you ever get a solution I’d be very happy heje
@nowomannocry8606
@nowomannocry8606 2 жыл бұрын
To give Internet access for my container, I just need to add - -net=host right? How about give access of my host webcam to my container? My container python script uses opencv lib
@christianlempa
@christianlempa 2 жыл бұрын
You containers have internet access, also if they're bridged. You usually don't need to add the net=host setting.
@samarthgoyal8791
@samarthgoyal8791 2 жыл бұрын
Hi there, I tried to do the same with another python code, but when i run the image through the terminal, I get a /bin/sh: 1: [python,: not found error. Can you please help me out with this? Thanks.
@christianlempa
@christianlempa 2 жыл бұрын
Sorry for late response. Seems like your Docker container hasn't installed Python. So maybe check your image version if everything is installed there, otherwise use another image that has Python installed.
@bellcanada719
@bellcanada719 Жыл бұрын
there is no vscode when json settings when i refresh
@webjakob
@webjakob 7 ай бұрын
While this simple tutorial worked well for me, trying to use docker-compose was bad - particularly bind-volumes just doesn't mount in vscode, while they work fine when using terminal docker-compose. But even just getting as far as launching the compose files was hard, and I had to research a lot and tweak launch.json and tasks.json a lot. Why doesn't vscode enable launching the composes, when it generates them??? So I vote YES, if you want to show how to make debugging docker-compose work ... AND bind-volumes! (I am on Fedora, and I am used to Pycharm).
@user-wr4yl7tx3w
@user-wr4yl7tx3w 2 жыл бұрын
do you have a version for Mac?
@mebeingme947
@mebeingme947 3 жыл бұрын
Nice video, just don't get it why you recommend ubuntu. In my experience the ubuntu mother, being Debian is much more stable, even if you use the testing branch.
@christianlempa
@christianlempa 3 жыл бұрын
My experience is that Ubuntu is pretty stable as well, but you also get newer software packages. I'm not 100% happy with Ubuntu either, but for a beginner it's definitely the best distro to start with (in my opinion 🤣)
@kk008
@kk008 2 жыл бұрын
Can't install Ubuntu 20.04 LTS what to do?
@xatazch
@xatazch Жыл бұрын
Now when Docker Desktop costs money. Do you have any good solution on how to create a docker image without using a build pipeline? Is there any good way to do this on windows using WSL?
@christianlempa
@christianlempa Жыл бұрын
You can still use Docker Desktop for personal use, so I don’t have an issue with it
@xatazch
@xatazch Жыл бұрын
@@christianlempa ya i know. Bit i want it for fast test builds in my company. I can do it via azure devops pipeline but it is alot more work to setup for a fast test. Thx anyway.
@developercontact490
@developercontact490 2 жыл бұрын
trying to follow simply explained tutorial but this no working on linux cause after pressing f1 the pop up (add docker to workspace) isnt showing how do i fix this sir
@christianlempa
@christianlempa 2 жыл бұрын
Don't know about linux, I've tested it on Windows.
@pedu71
@pedu71 2 жыл бұрын
simple type "docker add..." manually at > Prompt after F1
@fba1ra
@fba1ra 2 жыл бұрын
Hey Chris. Great Video. How do I deploy my container after I am done with development?
@christianlempa
@christianlempa 2 жыл бұрын
Thanks mate! Check out some Docker Tutorials on my Channel, that will exactly tell you how ;)
@fba1ra
@fba1ra 2 жыл бұрын
@@christianlempa Figured it out 😁
@svenkicherer
@svenkicherer 10 ай бұрын
Ist ein "Remake" des Videos mit vscode dev containern geplant?
@christianlempa
@christianlempa 10 ай бұрын
Hi, eher nicht da die Programmier Videos nicht so gut ankommen leider :(
@svenkicherer
@svenkicherer 10 ай бұрын
@@christianlempa zweitkanal 😉
@webjakob
@webjakob 7 ай бұрын
It's not pronounced "interpreTTer", but more like "interpretoerh". ;-)
@christianlempa
@christianlempa 7 ай бұрын
;D
@pythoneer44
@pythoneer44 Жыл бұрын
pywin32 will not work with this. No real solution
@renobodyrenobody
@renobodyrenobody Жыл бұрын
Ha sorry, I tried, but Windows... I can't.
@zachfenton608
@zachfenton608 Жыл бұрын
Auf Deutsch bitte. Gern geschehen
@christianlempa
@christianlempa Жыл бұрын
Nein Danke
Docker For Beginners: From Docker Desktop to Deployment
59:30
Travis Media
Рет қаралды 722 М.
How To Use Docker To Make Local Development A Breeze
21:53
ArjanCodes
Рет қаралды 295 М.
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41
Windows development setup with WSL2, ZSH, VSCode, and more
12:02
Christian Lempa
Рет қаралды 213 М.
Automate your Docker deployments with Ansible
20:32
Christian Lempa
Рет қаралды 88 М.
Using docker in unusual ways
12:58
Dreams of Code
Рет қаралды 400 М.
Powerful VSCode Tips And Tricks For Python Development And Design
15:50
you need to learn Docker RIGHT NOW!! // Docker Containers 101
23:19
NetworkChuck
Рет қаралды 2,6 МЛН
Learning Docker // Build Container Images
23:02
Christian Lempa
Рет қаралды 28 М.
Containerizing Python web apps with Docker, Flask, Nginx & uWSGI
25:38
The least you need to know about Docker!
13:57
Diolinux
Рет қаралды 238 М.
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41