How To Use Docker To Make Local Development A Breeze

Sdílet
Vložit
  • čas přidán 31. 05. 2024
  • 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: github.com/ArjanCodes/2022-do....
    🚀 Next-Level Python Skillshare Class: skl.sh/3ZQkUEN
    💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.
    💻 ArjanCodes Blog: www.arjancodes.com/blog
    🎓 Courses:
    The Software Designer Mindset: www.arjancodes.com/mindset
    The Software Designer Mindset Team Packages: www.arjancodes.com/sas
    The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
    Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
    The 30-Day Design Challenge: www.arjancodes.com/30ddc
    🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
    Check out @codeSTACKr and @JackHerrington's channel I mentioned in the video here:
    - / codestackr
    - / 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: discord.arjan.codes
    🐦Twitter: / arjancodes
    🌍LinkedIn: / arjancodes
    🕵Facebook: / arjancodes
    👀 Code reviewers:
    - Yoriz
    - Ryan Laursen
    - James Dooley
    - Dale Hagglund
    🎥 Video edited by Mark Bacskai: / 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!

Komentáře • 326

  • @ArjanCodes
    @ArjanCodes  Před 7 měsíci +3

    💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.

  • @heliophobicdude
    @heliophobicdude Před rokem +136

    I think it was brilliant to mention the ordering of commands in the dockerfile. It took me years to realize that ordering is the key to leveraging the build cache. Thank you!

    • @MMarcuzzo
      @MMarcuzzo Před rokem +3

      Never noticed about that. Gonna be aware of this now

  • @veni_vidi_victorian
    @veni_vidi_victorian Před rokem +44

    I have been working on exactly this (Making our FastAPI backend services available to our front-end devs locally through docker compose) at work for the past 2 weeks or so, where's the camera? :D Only difference was that I use poetry to install requirements, maybe a tool worth to explain in a video as well in the future? Love your content ☺️

    • @pacersgo
      @pacersgo Před rokem +1

      I see poetry is getting more and more popular. I am wondering what is the advantage of poetry over pip?

    • @veni_vidi_victorian
      @veni_vidi_victorian Před rokem +14

      @@pacersgo Poetry is using pip under the hood, and you can still use pip to install packages. There are a lot of benefits to poetry, but the main ones - for me - are:
      1) Project initialization
      Creating a project or initializing one with poetry can be very interactive if you wish it to be. Not leaving the terminal to google for package names or versions has never been easier! More staring at monospace fonts, 11/10.
      2) Builtin virtual environment
      With poetry, you have a built-in shell (initialized with "poetry shell" in your terminal) to run (package-specific) commands in your setup. You can't accidentally install black globally and run it on all your project folders anymore. In my opinion, it's also a lot more convenient than venv or conda.
      3) Configuration
      Poetry configuration is, well, poetry. The details you can fine-tune with in-/exclusions and that you can clearly separate required and optional dependencies are godsent for me.
      One TL;DR point worth mentioning, poetry shines most in environments where people share the codebase. Whether this is in an open-source scenario or in your closed-source company work, you don't have to worry about everyone needing the same setup on 6 different OSes. Your README will be "1. Install poetry (one curl command). 2. Run poetry install.". If you are using PyCharm, you are immediately notified of missing packages. (Not sure if VSCode has integration for this.)
      Okay, that's enough fanboying from me. Sorry for the wall of text. Hope you find some time to give it a try :D

    • @JustinBarak
      @JustinBarak Před rokem

      Poetry is the best

    • @aflous
      @aflous Před rokem +1

      Yes please, we need some poetry!

    • @HaithamSeelawi
      @HaithamSeelawi Před rokem +1

      If you guys liked poetry you have to give pdm a shot. It is much faster.

  • @user-hn1cy5ee5l
    @user-hn1cy5ee5l Před rokem +73

    It would be good to specify Dockerignore file as well, for example if you don't want to copy venv/ folder or precompiled python code (__pycache__ etc) into container (keep it small)

  • @christsciple
    @christsciple Před 9 měsíci +7

    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!

    • @ArjanCodes
      @ArjanCodes  Před 9 měsíci

      Thank you!

    • @sixpooltube
      @sixpooltube Před 8 měsíci +1

      Came from Patrick Loebers' video too and found Arjan's to be muuuch more clear.

  • @jonaszasut17
    @jonaszasut17 Před rokem +55

    I have few minor comments on this one, mainly because I'm working mostly with docker day-to-day:
    - use multi-stage builds, this example may not show it but docker images' size gets really blown out when you create many layers on them, in this example you could f.e. use venv in first part of the build (or poetry, tbh I recommend it as a package manager it blows the pip from earth) and then copy the venv to the second, much lighter image (f.e. python alpine)
    - I'd recommend to not use the latest image unless you're running some testing for building docker images, I've met some situations when something changed between let's say python3.6->3.9 and the docker image would be non functional
    - docker-compose for volume append only was a overkill, however I agree on the need of docker-compose files, they unify the work in the team. While using python with poetry you can also use the PoeThePoet for managing simple jobs as building docker image and then docker-compose up if you're making crucial changes in the code itself
    - I'd look into docker-slim after the two-stage images, Your image is probably ~800-900 MB, two stage build with alpine-python or python:slim would make it go to ~100-150MB and after docker slim you could be left with at most 50MB. I know that developers don't really care about that, but imagine having 10-15 images of yours size, that's 15GB of disk wasted
    - and the last thing, I'd recommend building with Kaniko (tool from google) instead of docker build, it's faster, produces slightly lighter images and has better caching at least in my experience

    • @lazyh0rse
      @lazyh0rse Před rokem +6

      Good points, however, your points are geared toward advanced users, most tutorials on the internet are really bad anyways, so getting started with this thing requires a massive commitment tbh.
      I appreciate your points, but by looking them on google, they are very hard to follow, because you have to have a good experience in using docker.
      As someone who just wants to build an image that just works, this alone is just a massive pain in the ass to get it to work for some reason.

    • @janekschleicher9661
      @janekschleicher9661 Před rokem +1

      @@lazyh0rse I'd always suggest to add a pre-commit linter for the Dockerfile, e.g. hadolint, that just checks most of the issues, especially the security critical ones (like not pinned versions). To be fair, for such an introductory video, that's probably a bit too much, especially as every linter will suggest to run the docker container as non root, what would add some further settings. But one reason for the poor security overall is that every introduction skips it, so nobody (initially) does it. For example, the --no-cache option, arjan is using here, is something that might be unintuitive (you rarely need it for local work), but very useful and hadolint would pin it (if not included here), too. That's why using linters and following as a result all the best practices you probably you can't know consistently, is really the way to go in practice. (Or just prepare already to get hacked :-o)

    • @alexanderpoplawski577
      @alexanderpoplawski577 Před rokem +3

      The docker-compose was not only for volume, but to add a different run command. The idea was to leave the Dockerfile for deployment unchanged and have specific runtime parameters for local testing. I think he mentioned the problems with latest for production. I didn't know about docker-slim, thanks for the suggestion.

    • @peterszilvasi752
      @peterszilvasi752 Před rokem

      When the comment is more valuable than the video. The slimtoolkit blows my mind. Thank you for the useful informations!

    • @jonaszasut17
      @jonaszasut17 Před rokem

      @@peterszilvasi752 glad I could be helpful!

  • @keyone415
    @keyone415 Před rokem +3

    nice video! but you don't need docker compose for the reload functionality, you can do the volume mapping from the docker run command and also override the uvicorn with the --reload:
    Here is the command to run: docker run -p 8080:80 -v $(pwd):/app --rm channel-api uvicorn main:app --host 0.0.0.0 --port 80 --reload

  • @GeorgMayer
    @GeorgMayer Před rokem +25

    i was avoiding docker for practically years now, but your great example here made me try it out now - thank you! Not only did it work in a day, it forced me to get a much cleaner base setup for my (old and "naturally grown") project. This injected a whole lot new joy - and a lot of possibilities.

  • @jajaramillo5
    @jajaramillo5 Před rokem

    On 3:44: the 0.0.0.0 IP address is not localhost; it means to the uvicorn service to accept requests from any IP interface on the server. While localhost is the127.0.0.1 IP address, which couldn't be accessed from outside of the server/virtual machine. Just to clarify!. Great docker guide for beginners.

  • @leeseoWestport
    @leeseoWestport Před rokem +1

    Feedback please for the downside of what I’m proposing. How about?
    1) Use the python image versions and install ssh server.
    2) Create a user, with sudo privileges. Also install other tools you may use: vim, git, zsh, procps, etc.
    3) Upon startup of the new image, have your host home folder (or dev) environment to the new user (in container) home folder.
    Also, re-assign uid and gid of your home to the container user, so we don’t have to worry about permissions and any new files created will also be your host machine’s user.
    When the container starts up, you run the sshd in foreground.
    This all can be coordinated in a startup script.
    Also, expose all ports necessary. I map ssh 22 of container to 2222 of my host machine.
    4) Use VSCode’s remote ssh extension to actually use the container environment. If your ssh keys are setup correctly, you can ssh without password to the container as the container user, which is equivalent to you since you re-assigned the uid/gid of the container user to your host user.
    5) Your VSCode now can do what you normally do on your host machine such as debugging inside the container. For VSCode, it’s as if you’re running completely inside the container.

  • @nickheyer
    @nickheyer Před rokem

    This is one of the best videos i've seen in a very long time. You so clearly explain this pipeline, anyone can pick it up. Here I am manually rebuilding docker containers every time I change code.

  • @express4863
    @express4863 Před rokem +1

    Another suggestion for future videos is VSCode + devcontainers + docker. I don't even bother using venvs any more, I just spin up a devcontainer and write my code in that.

  • @waikinmak5425
    @waikinmak5425 Před 10 měsíci +2

    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!

  • @tothestars3958
    @tothestars3958 Před 7 měsíci

    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.

  • @chikken007
    @chikken007 Před rokem +4

    Dear Arjen, really well done once again. I like how you build up the improvement of the docer-compose and reload feature on the second half of the video. This was just the content I needed. At work we are hosting dash apps and use poetry as a package manager but often we have trouble to get something running between the different developer environments. I would love to create a universal developer environment with docker. This lesson is a great starter.

  • @robertwolinski7294
    @robertwolinski7294 Před rokem +11

    I think a deployments video would be super beneficial. Many engineers and product managers alike take for granted you can "just deploy it" and don't realize there is nuance in doing it the right way.

  • @athakur33
    @athakur33 Před rokem +29

    I'm actually new to python but i love your way of teaching. There are some aspects that I don't understand but will learn as I start practicing.

    • @btkb1427
      @btkb1427 Před rokem +1

      Best of luck on your journey:)

    • @ArjanCodes
      @ArjanCodes  Před rokem +3

      Thanks Anand, glad to hear the videos are helpful to you.

    • @carecavoador
      @carecavoador Před rokem +4

      Trust me, you will. Just keep learning and most important: practicing. Arjan gave-me the motivation I needed to restart learning Python, the way he approaches it seems very refreshing to me. Since I started following this channel I already done four micro services to help me and my team with our work automating tasks. I'm saving money to get his course.

    • @btkb1427
      @btkb1427 Před rokem

      @@carecavoador his course is great :) you will not regret it!

  • @official.mhm13
    @official.mhm13 Před rokem

    The best comprehensive video which explains the whole process really well. Thanks a ton

  • @MichaelPayPlus
    @MichaelPayPlus Před rokem +4

    Your content is always so clear to understand and does a great job taking a learner through a journey that is easy to follow!

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thank you, Michael, glad you’re enjoying the videos!

  • @sixpooltube
    @sixpooltube Před 8 měsíci +4

    You are a f'ing amazing teacher. Most clear video of this topic on CZcams by far. Subscribed!

  • @SkipperChuck42
    @SkipperChuck42 Před rokem +8

    Love this. Very easy to follow, and a simple yet viable example which does not look like everyone else's copy/paste examples that are out there. Someone else mentioned a video on deployment - would like to put in a vote for that as well. I've done Docker and docker-compose for a long time, but the deployment aspect still eludes me. Obviously, there are nuances between cloud providers (Azure/AWS/GCP), but a simple example using one of them would be awesome if you could put it together. Thanks

    • @ArjanCodes
      @ArjanCodes  Před rokem +1

      Thanks so much, glad it was helpful!

  • @benyaminaghaebrahimi5073

    So far one the most detailed videos about docker. I've seen like more than 15 videos about docker but none of them mentioned the point that you pointed at 11:00. Please carry on posting, for someone like me who likes to learn these stuff these videos are very informative.

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks so much, Benyamin, Glad you liked it!

  • @golammuhaimeen2825
    @golammuhaimeen2825 Před rokem

    This was such a well composed video Arjan! Great work my man!

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thank you Golam, glad you liked the video!

  • @rothscha
    @rothscha Před rokem +1

    Really helpful step-bystep explanation on using docker for specific python project! Have you also planned to do prepare an ansible + Helm-chart example?

  • @AndrewAkaHrun
    @AndrewAkaHrun Před rokem +19

    Nice video! However using docker-compose to map the local folder seems like an overkill to me. You can simply add ‘-v .:/app’ to your docker run command and get exactly the same result. Anyways, looking forward to your deployment video!

    • @R1c0bones
      @R1c0bones Před rokem +2

      Both a great, compose you normalize across your team with git. But you also can create a script with -v. But then again... not all developers can execute scripts due security reasons ;)
      But thank you for the hint with -v.

    • @teeesen
      @teeesen Před rokem +1

      This is what I was wondering. What is docker-compose bringing to the table that isn’t already easy with Docker? I guess this video is only scratching the surface.

  • @shisus1803
    @shisus1803 Před rokem +4

    Really great video! Only thing I would like to ask is how do you manage the dockerfile used in the docker-compose config when you have different dependencies for prod, testing, local, etc.

  • @walid7189
    @walid7189 Před 4 měsíci

    So here's a great video on docker-compose, you have another on poetry, another on fastapi/pydantic. I would like to see a video demonstrating a good practice of a code base architecture with docker containers as services. For example, an API, that ~maybe~ uses a main package with pre-defined pydantic dataclass abstractions, which other services like the fastapi and idk, a separated Celery service that use mqtt and a database would use the same for handling that pydantic models.
    just an idea, thanks for your videos

  • @anishpatelwork
    @anishpatelwork Před rokem

    Been using docker compose for a while. Never realised that you could get hot reloads from it. I love this, going to be implementing it on Monday.

  • @dma98
    @dma98 Před rokem

    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

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Glad to hear you found it helpful!

  • @senX
    @senX Před rokem +7

    great as always, i'd really appreciate more about deployment options. right now im working on a laravel server with a gui and a python api server (flask) without guy and im not sure what the smartest deployment strategy is. i thought about putting the python server up with nginx and uwsgi on a linux vm, but you're probably way more experienced, so i'd love your take on this stuff

  • @BruceElgort
    @BruceElgort Před rokem

    Great and informative video. Thank you, Arjan!

  • @RealEstate3D
    @RealEstate3D Před rokem +1

    Clear, concise, to the point and working. Good job!!

  • @marna_li
    @marna_li Před 5 měsíci

    Thanks to Docker, I know have a great developer experience. I have a setup of services that I just can start with Compose. Then my services have been configured to use those locally. While in production, they just target the equivalent cloud services.

  • @dmmeteo
    @dmmeteo Před rokem +2

    Thank you man! Please make a separate video about different deployments. It is interesting 😉

  • @kevinlao3690
    @kevinlao3690 Před rokem +1

    Yes! Definitely would want to see a video on CI/CD and deployments in future. Always looking forward to learning from you

    • @ArjanCodes
      @ArjanCodes  Před rokem +2

      Thanks. I've put it on the list.

    • @kevinlao3690
      @kevinlao3690 Před rokem +1

      @@ArjanCodes looking forward to it :)

  • @arturkabitcher
    @arturkabitcher Před rokem

    Arjan, brilliant, as always! I tried to approach the topic several times but your video made it so clear to me that I now wonder why I didn't understand it before.

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks so much Artur, glad it was helpful!

  • @dmc549
    @dmc549 Před rokem +1

    This guy gets it. Great info, succinct, and to the point. Fast, while still jam packed with content. Subscribed.

    • @ArjanCodes
      @ArjanCodes  Před rokem +1

      Thanks Dean, glad you liked the video!

    • @dmc549
      @dmc549 Před rokem

      @@ArjanCodes Keep them coming exactly as you are. Learning so much.

  • @CoentraDZ
    @CoentraDZ Před rokem +1

    Great video as usual. Could you please continue another video like this deploying the same project in production ?

  • @shaishai416
    @shaishai416 Před rokem

    שידור ממש מעניין! תודה רבה על התשובות! בהחלט למדנו וקיבלנו כמה מסקנות טובות. גם על גיוון התיק,וגם על שאר הדברים!💥💯👏👏👏

  • @preritdas6998
    @preritdas6998 Před rokem

    Awesome. I find the best way to work with containers in this setting is to use a devcontainer. Completely removes the need for this type of docker-compose “magic” as Arjan called it.

  • @alexjando4880
    @alexjando4880 Před rokem

    Amazing video! It really helped me understand how docker actually works aswell as how to use it.

  • @malcolmanderson6735
    @malcolmanderson6735 Před rokem

    This is great, I've already got docker desktop installed, and following along was easy.
    And having your github link to clone, well it's "super easy, barely an inconvenience."

  • @RafaelGuedes84
    @RafaelGuedes84 Před rokem

    Hi Arjan, I'd love to see a video on the deployment strategies you mentioned. Thanks.

  • @d-shiri
    @d-shiri Před rokem

    Great, more docker videos please. Thanks

  • @Hubert4515
    @Hubert4515 Před rokem +2

    been using docker since 2018 as a dev, it was a game changer for me

    • @NostraDavid2
      @NostraDavid2 Před rokem

      It was a game-changer for the industry! I don't know if we'll use Docker in 10 years, but it's been a pyvotal (hehe) piece of software that gave us a paradigm shift on how we should build our software.
      Docker is great!

    • @Hubert4515
      @Hubert4515 Před rokem

      @@NostraDavid2 well said

  • @re.liable
    @re.liable Před rokem +1

    I've got some questions (for Arjan and/or viewers). Just starting to get into containerization
    • Does this mean I could skip creating a `venv` for my projects, build it as a Docker "app", and run the built image from a container (which contains all the needed dependencies)? I feel like the building step would be a potential bottleneck, but the caching Arjan showed may help with that
    • On the `docker compose` part of the vid, "volumes" were used, which overrides the copying of files into the `/app` directory. What if I wanted to run the Docker image/container on another machine? Would the files updated since the initial building be available there? Or do I also "package" the volume with the image/container?
    • How much space would Docker images/containers/volumes generally take up on my machine? I'm running a little low on storage now 😄

  • @pinch-of-salt
    @pinch-of-salt Před rokem +1

    Great video!
    Would be great if you could show other features that docker offers as well like network, more on volumes, etc.
    How would you debug using the container and not the python running on your machine?

  • @zaharius96
    @zaharius96 Před rokem

    Thank you for such useful videos, you’re great!

  • @stelioslagaras5334
    @stelioslagaras5334 Před 4 měsíci

    As a greek I fully approve the use of "homogenise" term! Very nice and quality video :)

    • @ArjanCodes
      @ArjanCodes  Před 4 měsíci

      Thank you so much! Glad you enjoyed it.

  • @richjohnson8261
    @richjohnson8261 Před rokem

    Nice and helpful video right when I needed it. Thanks!

  • @adriangonzalez7857
    @adriangonzalez7857 Před rokem +2

    Awesome video! What terminal do you use or how does it autocomplete commands?

  • @ipelezikis
    @ipelezikis Před rokem

    Great video again! The video about deployment you mention (6:08) would be a great idea.

  • @bartoszkrawczyk4976
    @bartoszkrawczyk4976 Před rokem

    I'm primarily working with node, not python, but this really helped me understand how to use docker. Thanks!

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thank you Bartosz, Glad it was helpful!

  • @user-pz3wg6ch9b
    @user-pz3wg6ch9b Před 5 měsíci +1

    Love and find it useful, also Grateful if you share what plugin or software that you are using to get a suggestion dropdown in the terminal.

  • @lardosian
    @lardosian Před rokem

    That was a nice simple explanation of Docker, fairly new to it myself so I'm gradually getting up to speed with it as we use it heavily in work on Cloudrun in GCP, thanks.

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks! I used Cloud Run in the past but was put off by the high cold start times and the limited routing options (for example no static IP address possible). Is this still an issue or have they improved things? If so, I might take another look at it.

    • @lardosian
      @lardosian Před rokem

      @@ArjanCodes I'm not 100% sure as I don't set up things from scratch. But I will say our senior devs think firestore is a bit of a joke as a database due to its query limitations.

  • @wlgrd7052
    @wlgrd7052 Před rokem +4

    Nice addition to your repertoire! 👌

  • @juanghpx
    @juanghpx Před 9 měsíci

    Thank you, great explanation and very helpful tips

  • @Horatio_101
    @Horatio_101 Před 5 měsíci

    10:50 Learned something new that I hadn't in other docker videos. Very nice!

    • @ArjanCodes
      @ArjanCodes  Před 5 měsíci

      Glad the video was helpful, Horatio!

  • @swapnilchavan7076
    @swapnilchavan7076 Před rokem

    Amazing video. Your channel is worth spending time. Everything is at it's place. More informative video with simplicity at it's best. Thanks for the video buddy. (In india buddy word is used in forces means the person you trusted most). Thank you.

  • @rajaramanv
    @rajaramanv Před 7 měsíci

    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.

  • @raphaelsoares7652
    @raphaelsoares7652 Před rokem

    Arjan, you made me a better python software developer, I love your content! Good job, keep it going! 🚀

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks Raphael, glad to hear the content is helpful. And will do 😉.

  • @user-mn8nn7rg3t
    @user-mn8nn7rg3t Před 5 měsíci

    Thank you very much. It was very helpful.

  • @_kopiter_
    @_kopiter_ Před rokem

    I wish, all of the dev stack would be covered by you :) so much useful info

  • @jorgev4656
    @jorgev4656 Před rokem

    Yes please talk about different types of deployment. Thxs

  • @kintukintu2098
    @kintukintu2098 Před rokem +1

    Finally!! Thank you so much for considering the request

  • @Akahatoo
    @Akahatoo Před rokem

    Cool video, quite simple in delivering the message and with great content!

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks Felipe, happy you’re enjoying the content!

  • @jenpen3249
    @jenpen3249 Před rokem

    Yes Arjan! Please make a video about deployment for applications/executable using Python, this pipeline is so undercovered!

  • @paertske
    @paertske Před rokem

    Thank you Arjan for your clear and concise videos! Your video editing is top-notch and you provide real-world examples that are even understandable for people from the Commodore 64 era. Your content is just the right depth, and I appreciate all that you do!

  • @jw3983
    @jw3983 Před 4 měsíci

    Thanks for this great video again! This really helps to get along with this new docker trend. Could you further explain the difference between a python virtual environment and a docker container? can i use both or is it even necessary to use a virtual environment within a docker container?

  • @esmaelmohamed8209
    @esmaelmohamed8209 Před 5 měsíci

    Arjan Please I need more docker, deployment also k8 i love the way you teach❤❤❤❤

  • @TorHagemann
    @TorHagemann Před rokem +11

    The main benefits of compose appear when you have more than one subsystem, e.g. a DB or cache (like redis) that is also involved in your project. (i.e. very often) Then, your containers can depend upon the DB and refer to 1) volumes, 2) networks, and 3) one another by name, along with some well-known ports, which are possible to expose and map (as desired) via the host node, no matter which port(s) the process in the container thinks it has bound.
    I would suggest: a second, follow-up video 🙂 that could go a little deeper into the basics of using Docker in development/otherwise--e.g. a Dockerfile should ideally include a USER directive so that the service doesn't "run as root" even inside the container, and expose 8080 to map to another port on the host. User management in a container might seem kinda "belt-and-suspenders" before you read about Docker CVEs, but it's really a good practice for peace of mind if nothing else!
    My personal style is also to keep docker-compose for dev only, and my Dockerfile (with build args where relevant, plus targets like `make dev` vs. `make image` in a Makefile) for dev/prod envs.

    • @ThePenitentOneArg
      @ThePenitentOneArg Před 8 měsíci

      Docker it's incredible for deployment but for development I always find easier ways to deal with it.
      If it's a Python app, poetry and pipenv provide pretty decent isolation so no dev environment is needed
      If it's a node app (like React), you can use nvm and specify version in a .nvmrc file
      What I find really useful is to define external services that are also dependencies of the project in a docker compose file. You can set RabbitMQ, Postgres, Redis and whatever you need there and use docker compose up to start everything

  • @edip_c
    @edip_c Před rokem

    Your videos are like (Python) poems or songs to me! Great job as always!!!👏🏻👏🏻👏🏻

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks so much Edip, glad the content is helpful!

  • @jithinsasikumar9576
    @jithinsasikumar9576 Před rokem

    Hey Arjan,
    Your videos are the best. It's well explained and precise. Keep up the good work. Just one request - If possible, please make a video series on MLOps !!!!!

  • @jeovaramos3709
    @jeovaramos3709 Před rokem

    Great video! Thank you a lot.
    Perhaps, you could do a video talking about CI/CD. I think it is the next level from here.

  • @silkogelman
    @silkogelman Před rokem +2

    Really nice Docker introduction, thank you Arjan! 🙏😀
    I love that you included how to handle automatic reload for changes in the data during development and the caching thingy
    Also I really like your code readability, for example that when you load the data you name it channels_raw, and that you name them channel when they become dataclass Channel Objects.
    More tutorials about Docker and deploying them would be very much appreciated!
    Also hoping for best practices on how to update code or container versions after deployment, especially when there is live database data involved.
    (In my case I've setup Docker containers for Django, PostgreSQL, Celery + Beat, Redis and pgadmin.)

    • @silkogelman
      @silkogelman Před rokem +1

      And if I can make a little suggestion: you may want to include something about PYTHONUNBUFFERED and PYTHONDONTWRITEBYTECODE for setting up the Dockerfile in your tutorials.
      Oh and about .env files, environmental variables for the deployment videos. Like for the database passwords and API keys etc.

    • @ArjanCodes
      @ArjanCodes  Před rokem +1

      Thanks Sil, happy you’re enjoying the content!

  • @davidl3383
    @davidl3383 Před rokem

    Thank your Arjan for this excellent video. Jut to be sure, i learn Python currently, if we use docker we don't need to use environments like pipenv or poetry exact? When we want to work on a project, we just activte a container and that’s al ?

  • @iamghezali
    @iamghezali Před 8 měsíci

    Thank you for the video, it helps a lot

  • @bberakable
    @bberakable Před rokem

    Fantastic video - much appreciated!🥰

  • @DavidFodor1
    @DavidFodor1 Před rokem

    Thank you Arjan for the video, amazing quality and content as always. I have a question regarding using docker in a local development environment. If I keep adding packages to my requirements.txt file docker-compose up is not installing them but rebuilding takes ages. Do you know what is the proper way to take care about this when in development? Is there a docker version of pip install?

  • @aljabadi9941
    @aljabadi9941 Před rokem

    Thanks for the amazing video :) I am curious what theme you are using in VSCode? It is elegant!

  • @BritleFoot
    @BritleFoot Před rokem

    marvelous, thank you!

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks so much, glad you liked it!

  • @edgeeffect
    @edgeeffect Před rokem

    Over in the PHP world, our bosses have a terrible obsession with running totally obsolete versions of PHP. For this, Docker is a godsend!

  • @lucienchardon6819
    @lucienchardon6819 Před rokem +1

    Great video, thank you! The only issue is that when i now switch from my local python venv development environment to the local docker env, VS code asks me for every project to install the development dependencies like black etc. Could you explain how you integrate your VS code python extensions with your docker workflow? Thanks!

  • @ajeetis
    @ajeetis Před rokem

    Simple, yet powerful

  • @qkz3es
    @qkz3es Před rokem

    easy to understand intro, nice video

  • @scarsellifi
    @scarsellifi Před rokem

    Great Video! regarding the chapter "Dealing with change in the data" is there a similar solution for gunicorn and flask?

  • @Han-ve8uh
    @Han-ve8uh Před rokem +2

    18:18 "you can change the code and when you save the file it will automatically RESTART THE CONTAINER because of the volume syncing option"
    1. Is the code update really because of volume syncing option? Isn't it because of the --reload flag in uvicorn? Whether we use VOLUME or --reload are 2 independent decisions with 4 possible permutations right?
    2. Does docker really restart the container for any change in files specified in volume? That doesn't make sense intuitively. If some process is writing to a local folder continuously (eg. 1 new file per second) and docker container takes more than 1 second to restart, the whole system breaks down. 19:23 also shows that only the process restarted with a StateReload detected changes WARNING log, but the container did not restart.

  • @stokestack
    @stokestack Před rokem

    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?

  • @lofmaan
    @lofmaan Před rokem

    Very nice tutorial, salute to you :)

  • @rohitpatil3534
    @rohitpatil3534 Před rokem +3

    Needed this for so long lol

  • @stello1972
    @stello1972 Před rokem

    Very nice. Very clear. Your pronunciation was spot on btw.

  • @vicidilochi
    @vicidilochi Před 10 měsíci

    Huge thanks

  • @TehProxy
    @TehProxy Před rokem +2

    at 12:56 what terminal are you using that gives you hovered suggestions for the command you're typing out?

    • @ArjanCodes
      @ArjanCodes  Před rokem +2

      I'm using Fig, it's free and it's really cool: github.com/withfig/fig

  • @fedegarro58
    @fedegarro58 Před rokem

    Excellent video! One question though:
    In your case you are working in with your local computer, but what's the "best practices" workflow for developing and testing an image (locally I guess) that is going to be deployed into a K8s cluster, and that has different hardware than my laptop?
    To explain the context a bit, I'm running some deep learning code that needs gpus and my laptop doesn't have any so I launch a "training job" into the K8s cluster (K8s is probably not meant to be used this way, but is the way that we use it where I work) and I'm not sure how I should be developing and testing my Docker images.
    At the moment I'm creating a container that has the desired gpu and manually running a bunch of commands till I can make the code work. Then, once I got the code running, I manually copy all the commands from history that made the code work and then copy them to a local docker file on my computer, compile it and push it to a docker hub, from which the docker image is going to be pulled the next time I launch a training job into the cluster, that will create a container from it and train the model.
    The problem with this approach is that if there's a bug in the image, I have to wait until the deployment to the container to realize that my Docker file is wrong and I have to start the process all over again to change it. Also finding bugs from the output of kubectl logs is very cumbersome.
    Is it a better way to do this?
    I was thinking of installing docker into the docker container and use IntelliJ (or any other IDE) to connect to the container via SSH and develop and test the image remotely; but I read in many places that this is not a good idea.
    What would you recommend then instead?
    Many thanks!!

  • @holographictheory1501

    I would love a video on FastAPI from you! Thank you for another great video, I was just thinking the other day how much I wanted your perspective on Docker

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Great suggestion, thank you! glad you liked the video!

  • @lker-dev
    @lker-dev Před 2 měsíci

    Is there a good trick to make the container python interpreter available so my IDE has better visibility of what is installed in the container or do i need to replicate the installs locally as well?

  • @Serbekh
    @Serbekh Před rokem +1

    Great video!
    Please show your VS Code config!

  • @dmenisdevdevelopment7158

    Nice, simple clear instructions. Would be nice to have seen how to debug (with breakpoints) in the container.

    • @ArjanCodes
      @ArjanCodes  Před rokem

      Thanks for the suggestion. I've put it on the list.

  • @a.7388
    @a.7388 Před rokem

    Will the changes with docker-compose propagate the other way around? For instance, if we make a change to a data file in docker, would the local file be changed too?

  • @Andremzsptm
    @Andremzsptm Před rokem

    Great video as always Arjan. You're approaching 100k subs too fast, congrats!

    • @ArjanCodes
      @ArjanCodes  Před rokem +1

      Thank you Andre, and yes, it’s going so fast!

    • @drooten
      @drooten Před rokem +1

      This might sound cliché, but don’t let those numbers change the simplicity of your presentations, or the depth of solutions. Appreciate all the effort you got to with these videos!

    • @ArjanCodes
      @ArjanCodes  Před rokem +1

      Thank you @Available Messenger! Though of course I'm very honored that so many people find my videos helpful, in the end the subscriber count is mostly a vanity metric. I'm mainly looking at metrics like viewing time and whether my existing audience is actually returning to watch more videos to determine what I should work on.