Docker compose tutorial for beginners by example [all you need to know]

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • You can find the related Docker Compose tutorial blog post with the sample code her: takacsmark.com...
    This Docker Compose tutorial video explains the following points:
    What is Docker Compose
    Compose file basics
    Preparing the example
    requirements.txt
    app.py
    Dockerfile
    Adding the Docker Compose file
    Run the example
    How are the containers connected
    Working with the Compose file
    The Docker Compose file reference
    Docker Compose vs Swarm
    The structure of the Compose file
    Service configuration options
    Build configuration
    Runtime configuration
    Deployment options
    Work with Docker Compose in your projects
    Compose CLI
    Build images with Docker Compose
    Use build arguments
    Manage multi-container applications
    Execute commands in a running container
    Run one-off commands
    Ship your multi-container applications
    The concept of desired state
    Scale a service with Compose
    Docker Compose networks
    Volumes and Compose
    Use env_file to pass environment variables
    Variable substitution
    Override the Compose file
    Docker Compose in production

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

  • @santhoshnagarajs3489
    @santhoshnagarajs3489 5 ปีที่แล้ว +7

    If anyone gets this error redis.exceptions.DataError: Invalid input of type: 'dict'. Convert to a byte, string or number first
    change the requirements.txt use redis==2.10. instead of redis

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      Thanks Santosh, indeed redis-py has changed, the example is broken with the new version.

    • @santhoshnagarajs3489
      @santhoshnagarajs3489 5 ปีที่แล้ว

      @@takacsmark Thank you for the video. It is very useful.

    • @marouane55
      @marouane55 5 ปีที่แล้ว +1

      @@santhoshnagarajs3489 In requiretements.txt change redis to redis

    • @koodauskanava9096
      @koodauskanava9096 5 ปีที่แล้ว +1

      You can just serialize your dict with json.dumps(data) when you store data and unpack it when you read data with json.loads(item)

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

      i dont mean to be off topic but does anybody know of a method to get back into an instagram account??
      I somehow forgot my password. I would love any help you can give me

  • @davidcantrell5627
    @davidcantrell5627 5 ปีที่แล้ว +2

    This is such an outstanding tutorial precisely because it provides an in-depth walkthrough of the subject without being overwhelming or running off on tangents. It deserves 100 times the views it has. Well done.

  • @gagangupta1255
    @gagangupta1255 5 ปีที่แล้ว +3

    One of the best and the easiest docker compose tutorial on web. Keep up the good work

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

    Great video, its sad that videos like this dont receive many views, but content like this is just not for wide audiences

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

    Sorry if this is a weird compliment, but you are very good at making eye contact with the camera. It makes the tutorial feel more personal

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

    The way you teach, with the smile on your face is really great 😍

  • @miles-levoit
    @miles-levoit 6 ปีที่แล้ว +6

    wow, so informative. That was world class! Merci beaucoup mon ami

  • @user-zk1im8he5j
    @user-zk1im8he5j 4 ปีที่แล้ว +1

    with my broke english i understood almost everything ! Best explication !!!! Thanks a lot!

  • @vivekraj5071
    @vivekraj5071 6 ปีที่แล้ว +2

    Very good, Please do upload videos on swarm.

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

    Great video. I learned a lot in this tutorial. I appreciate you putting this all together!

  • @chikosan99
    @chikosan99 5 ปีที่แล้ว +1

    Thanks a lot for your time ! Love your video

  • @the-raj-verma
    @the-raj-verma 3 ปีที่แล้ว

    Simply awesome, Thanks for the effort :)

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

    Excellent!. Thank you so much.

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

    Awesome tutorial, I wish to have you as my Team lead.

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

    Excellent 🙏 Thanks a lot. 👍

  • @superawesh
    @superawesh 5 ปีที่แล้ว +5

    already liked after watching 8 mins of content, MOST AMAZING DOCKER TUTORIAL WITH IN 50 MINS. TOTALLY WORTH SPENDING 50 MINS 👍 thanks #DockerExpert

  • @notpublic7149
    @notpublic7149 6 ปีที่แล้ว

    Sir, if you are not a professor, you should be... Cheers for the information mate. Crazy useful!

    • @takacsmark
      @takacsmark  6 ปีที่แล้ว +1

      Thanks, this is one of the funkiest comments that I got :)

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

    What a nice explanation! WOW! WOW! WOW! like the way of teaching.. Thanks a lot Mark! Happy Christmas! #Docker Expert

  • @foobar1672
    @foobar1672 5 ปีที่แล้ว

    Excellent tutorial. Thank you!

  • @koustavbanerjee9533
    @koustavbanerjee9533 6 ปีที่แล้ว +1

    Thank you so much for this introductory video.Could you also upload some more advanced videos as well in sequence to this?

    • @takacsmark
      @takacsmark  6 ปีที่แล้ว

      Hi Koustav, thanks for your feedback. What advanced topic would you like to be covered?

    • @koustavbanerjee9533
      @koustavbanerjee9533 5 ปีที่แล้ว

      @@takacsmark Hi takacsmark, Could you demonstrate deployment of slightly more complex applications using docker compose and swarm?

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

    Excellent

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

    I used Docker Compose to setup a LAMP environment but MySQLi isn't installed by default so I had to create a DockerFile and run some Bash commands to install MySQLi and commit it to the container. Is there a way to take this new environment I have with LAMP + MySQLi and export that so I can share it with the rest of the team?

  • @sudhansupradhan6891
    @sudhansupradhan6891 5 ปีที่แล้ว

    Great Tutorial !!!

  • @TellaTrix
    @TellaTrix 5 ปีที่แล้ว

    Seems you are pretty docker guy... Nice content.

  • @veryshafrudin3490
    @veryshafrudin3490 5 ปีที่แล้ว

    great job bro. nice tutorial

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

    Thanks for sharing very informative! I spy Terraform extension 👀. I will be interested to look for something like this video on Terraform if possible.

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

    Hi Mark, I am just wondering doesn't using the service name defined in the compose file as your host name in your app db connection tightly couple your application to docker ? What if you wanted to migrate to a different container like openshift ?

  • @amitjain561
    @amitjain561 5 ปีที่แล้ว

    If I am scaling service with a factor of 5 on tree node cluster then definitely the same service deployed multiple times on the same node. My question is related to dynamic port allocation, in service definition if we have configured - 8080:80 which means that internal container port is mapped to external port 80. How do we handle such scenario I assume that there will problem in replicating the same service if that service already running on the same node because port 80 is already in use. I am sorry if you have already covered such use case in your video. Many thanks, Mark for your wonderful work.

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      Hi Amit, if you are on a cluster, you need a container orchestrator like Docker Swarm or Kubernetes. Comopse is single host only. I'm writing my Swarm tutorial right now, but it's not yet ready :) You can buy my book though, to get started, or you can check out the only documentation of Swarm or Kubernetes. Swarm is built into Docker, so I would suggest to start with that. Scheduling, scaling and service discovery are all built in, so Swarm can cover your scenario. If you need application level load balancing, then you need to add a load balancer yourself to your deployment.

    • @amitjain561
      @amitjain561 5 ปีที่แล้ว

      @@takacsmark Ok got you Swarm or Kubernetes need for deploying services on a multinode cluster. Is there any way to avoid a port collision when running service replica on a single node using docker-compose command?

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      @@amitjain561 You can add a reverse proxy to your compose file and map it to port 80, a good docker image is github.com/jwilder/nginx-proxy.

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

    i need some help in docker containers and kafka

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

    How can I deploy it to the heroku ?

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

    I want to know what keyboard are you using please?

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

      Hi, I'm using this one www.coolermaster.com/catalog/peripheral/keyboards/quick-fire-xt/

  • @amitjain561
    @amitjain561 5 ปีที่แล้ว

    Docker Compose composes of different services. How could we manage dependency among them for e.g. my spring application can't boot without MySQL and if docker starts deploying spring app first then it definitely gonna fail do we have someway with docker compose to tackle corner case?

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      Hi Amit, thanks for the great question. You can add `depends_on` to the services in the Compose file to define if a service depends on an other service. Docker will make sure that the containers will be started in dependency order. This will, however not make sure that the service (like a db) is also ready to receive connections. Since every dependency is different, you have to do the check manually. You can write a shell script and add it to your ENTRYPOINT or CMD in the Dockerfile that checks if the db is ready and start up the depending server after. You can read more about this here docs.docker.com/compose/startup-order/.

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

    So many advertisement dude ... video is good

  • @kosmaspalios1768
    @kosmaspalios1768 5 ปีที่แล้ว

    woooop 18:38

  • @quangluong5413
    @quangluong5413 4 ปีที่แล้ว +3

    The explanation is amazing. I've been wandering around different Docker Compose tutorials but I have got the best idea out of this video. Keep up the good work and thank you!

  • @nomenetasaili7339
    @nomenetasaili7339 5 ปีที่แล้ว +4

    Thankyou, was trying to get my head around docker compose and this helped a lot

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

    best docker-compose tutorial i ever saw... thanks for all the information... :)

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

    Just tutorial for beginner
    Wordpress has weak point to connect to database directly without WEB API
    If you talk Docker compose it is better way to use local network in Docker
    Wordperss is END of Cotnents also PHP

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

    Hi, thanks for the video.
    In your Dockerfile you first copied the "requirements.txt" file and then installed the packages with pip. After that you copied all of your local files and directories into your container.
    Why not first copying all of the local files and directories into the container app directory and then install python packages with pip install -r "requirements.txt"?
    Is there any trick or something with doing that?

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

    I would like to ask you if you have any plans about preparing new tutorial series related with K8s?
    by the way your Videos about Docker are great, thanks

  • @askariBLT1989
    @askariBLT1989 5 ปีที่แล้ว +1

    It is a most thorough and easy to understand tutorial on docker-compose that I've found on TH-cam. Keep up the good work!!!!!!!!

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

    I wish there were a video about 'networks' explained by you. That would be awesome.

  • @asntube1
    @asntube1 5 ปีที่แล้ว +1

    The best docker-compose video tutorial that i have found. Congratulation!!!

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

    Awesome vedio sir..I learnt what I need, keep doing the good work.

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

    Amazing content. Thank you for sharing.

  • @Bargains20xx
    @Bargains20xx 5 ปีที่แล้ว +1

    Thank you so much for this

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

    Great guide, thank you.

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

    That was awesome thank you :)

  • @aisonnet
    @aisonnet 5 ปีที่แล้ว +1

    As a learner, I loved your explanation. Really appreciated.

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

    Fantastic explanation

  • @pramodkumar-hi3hn
    @pramodkumar-hi3hn 4 ปีที่แล้ว

    Thanks a lot

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

    Thank you so much for the video. Just the right amount of detail and great pace. Clearly explained some concepts I'd just taken for granted. I've subscribed and look forward to learning more.

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

    The best docker compose lecture I have ever found !!! Thank you !!! I don't understand who are those people who have pressed disliked button. This is best video one can get for understanding the docker-compose ecosystem...

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

    This video is so underrated, the best course on docker compose I have taken. I am in 2020 and this crash course virtually thought me about things I have been using without prior proper understanding.

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

    Great tutorial @takacsmark. Do you've any knowledge of why we use `mutagen` with docker. Any pointer would be helpful. Thanks

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

    Congratulations!, The first one in internet who explain so well docker-compose. Fantastic. Thank you. After hours of searching.

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

    I seldom comment, but this is the best docker-compose tutorial I have ever watch. Keep up the good video coming. subs :D

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

    Thanks for this awesome tutorial!! Just curious, what editor/ide are you using?

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

    You should be creating more videos because you really know how to transfer knowledge. Great video

  • @dsmolero
    @dsmolero 5 ปีที่แล้ว

    Thank you very much! Kudos to you Mark! You impart knowledge very systematically and very clearly. -- from the Philippines.

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

    This is a very informative tutorial for beginners. Thanks for the good work.

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

    The way you teach with the smile on your face always is really great to watch! Thank you for this tutorial 😊

  • @kailashdim7560
    @kailashdim7560 5 ปีที่แล้ว

    Thanks for such a good video and explaining everything which is required.

  • @JigneshPatel-bw5pq
    @JigneshPatel-bw5pq 5 ปีที่แล้ว

    Thanks Mark, It is very hepful tutorial.....

  • @justlstn
    @justlstn 5 ปีที่แล้ว

    Thank you so much for a video. It's very helpful

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

    The way you teach, with the smile on your face is really great 😍

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

    Nice tutorial, keep up the great work, Márk! :)

  • @rinav4all
    @rinav4all 5 ปีที่แล้ว

    Thank you for the amazing series of tutorials along with followup blog. It's pretty handy and useful

  • @santhoshkumarkasarla
    @santhoshkumarkasarla 6 ปีที่แล้ว

    Thank you nice video please upload other videos

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

    Very neat explanation, loved it !!!

  • @abdulmateenmohammed7103
    @abdulmateenmohammed7103 5 ปีที่แล้ว

    Excellent Mark, thanks a tonne :-)

  • @santoshsahani2129
    @santoshsahani2129 5 ปีที่แล้ว

    Nice tutorial on docker compose. Thank you !!

  • @gabrielmarrocos8993
    @gabrielmarrocos8993 5 ปีที่แล้ว

    Great video! Thanks!

  • @denizevsen6938
    @denizevsen6938 5 ปีที่แล้ว

    thanks for this helpful tutorial :)

  • @matmccann
    @matmccann 5 ปีที่แล้ว

    Best docker-compose tutorial out there. Thank you so much!!

  • @ZaheeruddinBabur8
    @ZaheeruddinBabur8 5 ปีที่แล้ว

    Awesome tutorial

  • @mahimainathansowrirajan2551
    @mahimainathansowrirajan2551 5 ปีที่แล้ว

    Its Great Tutorial!

  • @VinayKumar-pi4wm
    @VinayKumar-pi4wm 5 ปีที่แล้ว

    good one

  • @filipvanreeth
    @filipvanreeth 5 ปีที่แล้ว

    Hi cool video. Which vs code theme are you using. Looks like a nice one

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      Hi, that's the Quiet Light theme, that's built into vscode. I moved on the Dracula in the meantime, btw. :)

  • @amitjain561
    @amitjain561 5 ปีที่แล้ว

    Mark great work - hats off for you. I have one doubt when you dropped compose file on play-with-docker server what happened to Dockerfile referred in compose file?

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว +2

      Good question, this is an important point. When we drop the compose file to the server, we will use the image that is specified in the compose file. What happens is that docker-compose will pull the image from the Docker hub and it will NOT build it from the Dockerfile. This is possible, because we pushed our image previously to the Docker hub. This implies that we do not need to drop the Dockerfile to the server, we are not building the image on the server, we pull the image from the HUB. This is important, because this is how you should do it on a real project. Build the image, push it to a registry and pull it on your server. Your deployment entity is the image, not the Dockerfile.

    • @amitjain561
      @amitjain561 5 ปีที่แล้ว

      @@takacsmark Thanks Mark for swift response and making more clear :)

  • @binnihh
    @binnihh 6 ปีที่แล้ว

    You are awesome!

  • @pareenvatani9460
    @pareenvatani9460 5 ปีที่แล้ว

    Super like :-)

  • @venkateshjavaji2875
    @venkateshjavaji2875 5 ปีที่แล้ว

    One of the best on docker-compose!! Tq

  • @thrivenithrives2303
    @thrivenithrives2303 5 ปีที่แล้ว

    How to share a single terminal between two or more containers for printing data parallelly

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      Hi Thriveni, using docker-compose up will automatically print the standard output of all containers to your terminal.

    • @thrivenithrives2303
      @thrivenithrives2303 5 ปีที่แล้ว

      @@takacsmark but I need to up the all containers parallel not to sequencially

    • @thrivenithrives2303
      @thrivenithrives2303 5 ปีที่แล้ว

      Thank you for your reply but in the case of docker compose up it runs the containers one by one but I want to up all containers simultaneously

    • @takacsmark
      @takacsmark  5 ปีที่แล้ว

      What are you trying to achive exactly? Compose will start up a container for every service in the compose file. They will all start up after you issue the command. They start up one by one, but compose manages them together. What's your use case?

    • @thrivenithrives2303
      @thrivenithrives2303 5 ปีที่แล้ว

      @@takacsmark In my case one container need to print hello-world continuously and another container need to print like thriveni for random time at the time of first container running after random time it need to switch to second container and after completing the printing of second container again it need to trigger the first container like that need to switch containers from one to another.It is like the two containers were sharing the terminal

  • @junaid45678
    @junaid45678 6 ปีที่แล้ว +1

    You are great. Could you please improve the sound quality of your videos? It's not only very low but also a bit of drum effect is present.

    • @takacsmark
      @takacsmark  6 ปีที่แล้ว

      Thanks, I will look into sound definitely, I got comments on the loud keyboard, too.