How To Use Docker To Make Local Development A Breeze
Docker is a very powerful tool for developing applications that run in the cloud. If you want to get the most out of it, you need to make sure that the way you’re running your code locally matches as closely as possible with how it runs in the cloud.
Today I’m going to show you how to do this, using a simple API server in Python as an example. The code for this episode is available on GitHub: https://github.com/ArjanCodes/2022-docker.
🚀 Next-Level Python Skillshare Class: https://skl.sh/3ZQkUEN
💡 Get my FREE 7-step guide to help you consistently design great software: https://arjancodes.com/designguide.
🎓 Courses:
The Software Designer Mindset: https://www.arjancodes.com/mindset
The Software Designer Mindset Team Packages: https://www.arjancodes.com/sas
The Software Architect Mindset: Pre-register now! https://www.arjancodes.com/architect
Next Level Python: Become a Python Expert: https://www.arjancodes.com/next-level-python
The 30-Day Design Challenge: https://www.arjancodes.com/30ddc
🛒 GEAR & RECOMMENDED BOOKS: https://kit.co/arjancodes.
Check out @codeSTACKr and @JackHerrington’s channel I mentioned in the video here:
– https://www.youtube.com/c/codeSTACKr
– https://www.youtube.com/c/jackherrington
👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
💬 Discord: https://discord.arjan.codes
🐦Twitter: https://twitter.com/arjancodes
🌍LinkedIn: https://www.linkedin.com/company/arjancodes
🕵Facebook: https://www.facebook.com/arjancodes
👀 Code reviewers:
– Yoriz
– Ryan Laursen
– James Dooley
– Dale Hagglund
🎥 Video edited by Mark Bacskai: https://www.instagram.com/bacskaimark
🔖 Chapters:
0:00 Intro
1:04 Explaining the code example
3:22 Running the server locally (without Docker)
5:05 Docker & cloud deployment
6:45 Issues with running code in your local development environment directly
8:01 Building and running a Docker container locally
14:40 Docker-compose introduction
15:54 Docker-compose YAML file example
19:32 Dealing with changes in the data
#arjancodes #softwaredesign #python
DISCLAIMER – The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!
by ArjanCodes
linux web server
💡 Get my FREE 7-step guide to help you consistently design great software: https://arjancodes.com/designguide.
This is a seriously well done explanation not only of Docker, but of good development environment setup in general. I'm working to get my team more in sync with these kinds of practices.
Youre superior for creating this web hosting video! Ive experimented with GoDaddy and A2 Web Hosting, but Cloudways with TST20 coupn is the ultimate saver.
Youre superior for creating this web hosting video! Ive experimented with GoDaddy and A2 Web Hosting, but Cloudways with TST20 coupn is the ultimate saver.
The lighting for the video is good, but please pay more attention to the audio. You can probably use a collar microphone or equalize the volume in post production. Thanks for the great content.
🎯 Key Takeaways for quick navigation:
00:00 🐳 Docker helps ensure local development matches cloud environment for compatibility.
01:29 🐍 A simple Python API example using FastAPI to retrieve YouTube channel information.
03:21 🚀 Unicorn used to run the server, exposing it on port 8080, with an option for automatic reloading on code changes.
05:16 🌐 Docker provides an isolated environment for running applications, reducing compatibility issues between different environments.
07:12 🤝 When working in a team, it's crucial to make development environments as similar as possible to avoid errors.
09:08 🏗️ Docker images are built based on Dockerfiles, specifying the environment and dependencies for an application.
12:01 🔄 Manually restarting the Docker container for code changes is inefficient; Docker Compose offers automatic reloading for local development.
15:30 📁 Docker Compose uses a YAML file to define settings for building and running containers, including volume syncing for code changes.
19:19 🔄 Use "reload include" in Docker Compose to specify which files to monitor for changes and trigger automatic server reloads.
21:42 📦 Docker allows for flexible, isolated, and synced virtual development environments, ensuring compatibility between local and cloud deployments.
Made with HARPA AI
Thank you for the video, it helps a lot
You are a f'ing amazing teacher. Most clear video of this topic on YouTube by far. Subscribed!
make video about docker, spend 2 minutes walking thru basic python api.
I've been developing software for 20+ years and always used virtual environments for Python – I feel really behind the curve here, but have been curious about utilizing containers and watched a number of videos. Yours is easily the most clear, concise, and logically understood tutorial I could find. I had previously tried Patrick Loebers tutorial but found he had missed a number of critical steps and made a non-trivial amount of formatting errors.
So thanks for this tutorial, much appreciated!
"Home – ah – gen – ize"
Thank you, great explanation and very helpful tips
Thanks Arjan, this is an awesome video! The problem–solution–problem–solution format really helps me understand why we need docker and docker-compose. Also the tip of putting the install dependencies command before copying project folder is so important. Keep it up man!
Huge thanks
would be nice a video about dev containers / github codespaces
Hi! Which plugin you are using for zsh to have such nice intellisense?
Very helpful, thanks. At 09:17 you talk about building your image upon the python:latest image; where does that come from? Is this the name of an image that's made available by someone somewhere? Where is it retrieved from?
Yet again Arjan saves the day. I was smashing my head for hours trying to figure out how to setup a CMD command in the Dockerfile with lektor instead of uvcorn, where the commas and quotes are etc. Not only it helped me with that, but it showed me that I can actually just write the full command in the compose file, so I don't have to deal with all the specifics
7:42 It's pronounced "Hoe-MAH-gen-ize".🙂 Your English is nearly perfect–I'm surprised you had trouble with that word.
No matter how you pronounce it, though, your content is great!!
Clear, concise, to the point and working. Good job!!