Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9

Sdílet
Vložit
  • čas přidán 12. 06. 2024
  • In this Docker Compose Tutorial you will learn what Docker Compose is, why it's useful and how to use it.
    ► Subscribe to me on CZcams: bit.ly/2z5rvTV
    Docker Compose is a tool that makes running multiple Docker containers much easier, than with Docker run commands. I show you how docker run command compares to a docker compose file and explain step by step the difference and how it maps from docker run to a docker compose field.
    So, basically you can take the whole docker run command with it's configuration and map it into a file. You will get a more structured and re-usable command, especially if you have e.g. 10 docker containers.
    ▬▬▬▬▬▬ T I M E S T A M P S 🐳
    0:00 - Intro
    0:07 - What is Docker Compose?
    1:22 - docker run commands VS docker compose
    5:05 - How to use it? - Create the Docker Compose File (Demo)
    7:25 - Docker Networking in Docker Compose
    #devops #techworldwithnana #docker #dockertutorials
    -----------------------------------------------------------------------------------------------------------
    Once you've learnt the basic concepts, it's important to see how Docker is actually used in practice or in real world development so to say.
    In the next few videos "Docker in Practice" I want to show you exactly this:
    Developing with Docker ► • Developing with Docker...
    Docker Compose ► • Docker Compose Tutoria...
    Dockerfile ► • Dockerfile Tutorial - ...
    Private Repository ► • Private Repository exp...
    Deploy your containerized Application ► • Deploying the containe...
    You can check out my videos for the Pre-Requisites:
    ✅ Basic Docker Concepts: • What is a Docker Conta...
    ✅ Basic Commands: • 8 Basic Docker Command...
    For any questions/issues/feedback, please leave me a comment and I will get back to you as soon as possible.
    ►► Full Docker and Kubernetes Tutorial Playlist: bit.ly/2YGeRp9
    This video is the 9th of a complete series for beginners.
    💡 Only interested in Docker?
    ►► Complete Docker Tutorial Playlist: bit.ly/2ymJHbX
    #docker #whatisdocker #dockertutorials #devops #techworldwithnana
    -------------------------------------------------------------------------------------
    The complete step-by-step guide to Docker and Kubernetes will include the following content:
    🐳 D O C K E R
    - Container concept
    - Why docker? (image vs. traditional DevOps)
    - Install docker on different operating systems
    - 8 basic commands you need to know
    - Docker vs. Virtual Machine
    - Docker in Practice: Overview of whole development process with Docker (development, continuous delivery, deployment)
    - Develop an application with Docker
    - Docker Compose
    - Dockerfile
    - Private Repository
    - Deploying your containerized application
    - Docker Volumes from theory to practice
    ✵ K U B E R N E T E S
    - Main Kubernetes components (including Pod, Service, Ingress, Volumes, ConfigMap, Secrets, Deployment, StatefulSet)
    - Kubernetes architecture for beginners (master, slave nodes & processes)
    - Understand how does K8s REALLY work? Main Concepts of how to use K8s
    - Minikube, Kubectl - set up the cluster and connect to it
    - Kubectl main commands - Demo
    - Configuration file (YAML) - syntax
    - Kubernetes Namespaces
    - Communication between the pods - basic networking concepts in Kubernetes
    - K8s Deployment in practice - example application deployment (pod + service + Ingress + secret)
    ▬▬▬▬▬▬ Connect with me 👋 ▬▬▬▬▬▬
    Join private Facebook group ► bit.ly/32UVSZP
    Don't forget to subscribe ► bit.ly/3mO4jxT
    DEV ► bit.ly/3h2fqiO
    INSTAGRAM ► bit.ly/2F3LXYJ
    TWITTER ► bit.ly/3i54PUB
    LINKEDIN ► bit.ly/3hWOLVT
    Legal Notice:
    Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein. This video is not accredited, certified, affiliated with, nor endorsed by Docker, Inc.

Komentáře • 138

  • @StormWolf01
    @StormWolf01 Před 3 lety +55

    After searching "docker compose tutorial", i was hesitating, not knowing which tutorial to watch. Then i saw your video and i clicked. I've watched a lot of your toturials and I trust you, so i choose to watch your video with 8k views over that other guy with 850k views. You always explain things well.

    • @TechWorldwithNana
      @TechWorldwithNana  Před 3 lety +2

      That is so great to hear! 😊 Thank you so much for your support!

    • @Sudeep369
      @Sudeep369 Před rokem

      ​@@TechWorldwithNana I am getting an error "Additional properties are not allowed". And in the .yaml file, "services" is having an errr like "Property services is not allowed". Could you please help.

  • @TechWorldwithNana
    @TechWorldwithNana  Před 4 lety +8

    0:07 - What is Docker Compose?
    1:22 - docker run commands VS docker compose
    5:05 - How to use it? - Create the Docker Compose File (Demo)
    7:25 - Docker Networking in Docker Compose
    👉🏼 For any questions/issues/feedback, please leave me a comment and I will get back to you as soon as possible.
    👉🏼 Also please let me know what you want to learn about Docker & Kubernetes.
    Also please don't forget to subscribe and give me a thumbs up if you liked my video 🤓

  • @janphillips7177
    @janphillips7177 Před 2 lety +3

    I like how clear, straightforward and easy to understand you make this. It makes me think you have a really good understanding of how this works! Thank you

  • @captainfuture2882
    @captainfuture2882 Před 2 lety +3

    This explanation is so much better most of the other ones on CZcams. Thank you!

  • @carlellis9647
    @carlellis9647 Před 2 lety +10

    Once again Nana has put together another absolutely brilliant video. I have learned more about Docker from her than any other source. She has a wonderful talent for explaininng concepts clearly and compreshensively.
    Keep up the good work Nana, what you do a a wonderful gift to developers all over the world. :)

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

    Nana, you make everything so simple.

  • @mohan6244
    @mohan6244 Před 4 lety +29

    This is the best tutorial to understand docker very easily. Thank you very much for these videos. 🙏

    • @TechWorldwithNana
      @TechWorldwithNana  Před 4 lety +2

      You're welcome, glad the videos are so helpful :) Would appreciate your support by sharing my videos 🙂💙

  • @mirrormirage0
    @mirrormirage0 Před 4 lety +11

    Thank you for this! Clear explanation.

  • @danielderakhshani3316
    @danielderakhshani3316 Před 3 lety

    You explained docker-compose better than anyone else, you make it crystal clear

  • @kakhatezelashvili3368

    I am so proud that you are Georgian ! Hats off :) Docker topics explained the simplest possible way. What a quality, what an explanation. Wish you all the best👍👍👍

  • @bhupenderbhardwaj6991
    @bhupenderbhardwaj6991 Před 3 lety

    Whenever I have a complex concept to learn "TechWorld with Nana" is my last resort and you never disappoint me !! This tutorial is yet again a saviour !!

  • @RyuZaKi1925
    @RyuZaKi1925 Před rokem

    Very clear explanation. Best series saw on Docker. Keep going!

  • @sshbk5878
    @sshbk5878 Před 2 lety

    Thank you, Nana! May God bless you!

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

    Nana, you are turning me into a DevOps guru. Thanks you so much for all your brilliant videos.

  • @milad8436
    @milad8436 Před rokem

    Very well explained. I learnt Docker with all its tools from you completely. Thank you so much

  • @jaimecarranza2509
    @jaimecarranza2509 Před měsícem

    I needed to review some conceps and I am glad that I came back to this amazing video. Thanks a lot Nana.

  • @nully.emptier
    @nully.emptier Před rokem

    this is what I needed, transission from cli commands to config file, many thanks for great tutorial

  • @Weirlive
    @Weirlive Před 3 lety +1

    this was a great tutorial, thank you!!!

  • @lorenzomijorus
    @lorenzomijorus Před rokem

    thank you, very useful
    quick start guide

  • @meowcula
    @meowcula Před 2 lety

    That's for this. It was concise and easy to follow.

  • @AnandKumar-dc2bf
    @AnandKumar-dc2bf Před 3 lety +2

    Excellent explanation. I would rate 5/5 for this video..

  • @thumpanekolla2661
    @thumpanekolla2661 Před 3 lety +1

    Nana is THE Angel of DevOps. Hats off for your effort !.

  • @jatinhabibkar
    @jatinhabibkar Před 3 lety

    Amazing really u first explained the commands to create images and networks and then u introduce the yaml file it just hit the sweat spot on my brain thanks for this amazing series.

  • @moss1098
    @moss1098 Před 2 lety +4

    Great tutorial series!
    Adding "restart: always" to the mongo-express part of the yaml fixed a start-up error for me where mongo-express would exit if mongo wasn't ready for it.

    • @colofthedead6101
      @colofthedead6101 Před 2 lety

      Thanks - I was trying all sorts of things to get this to work!

  • @zaibakhanum203
    @zaibakhanum203 Před 2 lety

    Mam trust me u r clearing all the concepts which i was struggling to understand for such a long time..thank u soo much..

  • @Lunolux
    @Lunolux Před rokem

    that some great video here, i cant stop watching, very well explained thx

  • @brainattack11
    @brainattack11 Před rokem

    Thank you vary much for your tutorials! They are very helpful for beginners like me)

  • @kipitrash9403
    @kipitrash9403 Před 3 lety +1

    You have great tutorials. Thank you, that is all.

  • @jordancode
    @jordancode Před rokem

    Amazing video, as always.

  • @shivashrestha3781
    @shivashrestha3781 Před 2 lety

    wow very much helpful thank you!!!

  • @ankur3204
    @ankur3204 Před 3 lety +2

    Thanks
    Awesome.

  • @bishalgautam3874
    @bishalgautam3874 Před rokem

    Nicely explained 👍👍👍

  • @hamidja1537
    @hamidja1537 Před rokem

    Thanks for sharing

  • @Dan-hh7ve
    @Dan-hh7ve Před 3 lety

    Thanks Nana!

  • @daviddonadze221
    @daviddonadze221 Před 2 lety

    Thank u so much

  • @aminembarek6741
    @aminembarek6741 Před 3 lety

    It was very helpful

  • @aminembarek6741
    @aminembarek6741 Před 3 lety

    impressive work

  • @Deimosster
    @Deimosster Před 3 lety +1

    Keep it up! Great Job!

  • @ElLuben
    @ElLuben Před 3 lety

    WOW soooooo good!

  • @alimkugotov7193
    @alimkugotov7193 Před 2 lety

    thank you :3

  • @gayathrichakravarthy1056

    Thank you for this great intro - helps me to immensely wrap my head around something I am picking at work. I was wondering if you could help understand what context means within a compose file? Seems to me like a pointer to another dockerfile? Many thanks

  • @superspectator123
    @superspectator123 Před 4 lety +1

    Looking forward to the next videos.

  • @4rollingstone
    @4rollingstone Před 3 lety

    Good one Nana. 👍

  • @jonno9891
    @jonno9891 Před 2 lety

    Nice one.

  • @rbfreitas
    @rbfreitas Před 3 lety

    Great video

  • @tyagisong
    @tyagisong Před 2 lety

    brilliant

  • @elmokhliss4852
    @elmokhliss4852 Před 3 lety +1

    Thanks

  • @deepinpact035
    @deepinpact035 Před 3 lety

    Thank you... :)

  • @omidsarei3718
    @omidsarei3718 Před 3 lety

    I have watched lots of tutorials about docker,docker-compose and volumes then found out she explained everything way better than those i have watched so far.appreciate it

  • @bahriddinjava4381
    @bahriddinjava4381 Před 2 lety

    thanks

  • @anushavengsarkar6299
    @anushavengsarkar6299 Před 3 lety

    Thanks for that nice explanation about docker with examples. However it would be helpful if you can put more details around how to control startup and shutdown order in docker Compose". Thanks in advance.

  • @usmannajeeb3820
    @usmannajeeb3820 Před 3 lety +2

    Each video is more amazing then the previous one!

  • @pramodkumar-hi3hn
    @pramodkumar-hi3hn Před 4 lety +1

    Thank you Mam

  • @georgesmith3022
    @georgesmith3022 Před 3 lety

    thank you for the wonderful series. I have a question. Can you specify in docker-compose the -d option like in docker run -d or is it not possilbe?

  • @navneettiwari9176
    @navneettiwari9176 Před 2 lety

    Nice

  • @ashishmishra1212
    @ashishmishra1212 Před 2 lety

    Thank you so much great tutorials series, I have tried to work for myself, but facing an issue with the mongo express. Suppose I have run the express with port 8081 not working a second time with the same port, Any suggestion for the same?

  • @Poqonos
    @Poqonos Před 4 lety +5

    Thank you for the great tutorial series. Is there any way you can specify container and network name in docker-compose instead of defaults

    • @TechWorldwithNana
      @TechWorldwithNana  Před 4 lety +7

      Thanks! sure, you can add your own network name is docker-compose. here is an example:
      version: '2'
      services:
      postgresql:
      image: postgres:9.6.17
      ...
      networks:
      - my-network-name
      postgresql-test:
      image: postgres:9.6.17
      ...
      networks:
      - my-network-name
      networks:
      my-network-name:
      When you execute docker-compose up, you can check:
      1. docker network ls -> that the network was created
      2. docker network inspect my-network-name -> that the containers are running in that network
      Hope this helps!

  • @stallman3738
    @stallman3738 Před 6 měsíci +1

    Nana, Would you please upload a tutorial video about Docker Swarm on CZcams. Thanks.

  • @juleswombat5309
    @juleswombat5309 Před 4 lety

    Awesome stuff.
    Is there a way of naming the internal network, rather than the default app_?

  • @massmedia6516
    @massmedia6516 Před rokem

    Your are just pretty awesome...

  • @amnashome5650
    @amnashome5650 Před rokem

    Thank you Nana for the wonderful explanation. I watched all the previous videos so it's more clear from commands to docker-compose. I have one query regarding the container name the docker-compose that is creating. In the yaml file, we specified the name as mongodb, and then docker-compose created the container with that name along with some suffix and prefix. Could you please give me more details on how it's generating that prefix and suffix?

  • @HemangJoshi
    @HemangJoshi Před 3 lety +1

    very good video maam...

  • @kirankumarkkk7661
    @kirankumarkkk7661 Před rokem

    ty..

  • @user-or7ji5hv8y
    @user-or7ji5hv8y Před 3 lety

    Cool

  • @gabrielcsik2712
    @gabrielcsik2712 Před 3 lety

    I would like to ask you why do you specify and expose the port on host for mongodb if the docker network already connects them because of internal network? Don't we only need to expose the mongo-express port on host? If I understood it wrong, please correct me. Thanks for an awesome video.

  • @brianshanahan3878
    @brianshanahan3878 Před 4 lety +1

    I love your videos so far. I am watching from the begining as a refresher but came to learn the k8s portion. Question for this video is at 10:58 when you start "server.js", I did not catch where / when you created this. Is there a Git repo somewhere that compliments this video? Sorry to ask a distracting question... :)

    • @fuffsec
      @fuffsec Před 3 lety +1

      gitlab.com/nanuchi/techworld-js-docker-demo-app

  • @YL-pl1ek
    @YL-pl1ek Před 2 lety +1

    Cool channel like this.....
    so I will disable my ad blocker on this channel

  • @fatemepourghaemi2587
    @fatemepourghaemi2587 Před 3 lety

    enjyed it sm

  • @BenMick
    @BenMick Před 2 lety

    If you have a couple of services that you are running (not as part of your own built apps) is it good convention to split them up into individual docker compose files or have them all as one? Also, where should docker compose files go?

  • @milanthumar2747
    @milanthumar2747 Před 4 lety +2

    Hi Nana, You presented really good way. The material and presenting skill is really special to me.
    I would like to learn how exactly I can make presentation like you. Can you teach me same?

    • @TechWorldwithNana
      @TechWorldwithNana  Před 4 lety

      Thanks Milan, do you mean the video editing? I do these with Screenflow :)

    • @milanthumar2747
      @milanthumar2747 Před 4 lety

      very nice can you teach me in a session how to create presentation and video what you doing very nicely

  • @EliasAbuZolof
    @EliasAbuZolof Před 2 lety +2

    Hey Nana after trying to the apply the same fields on docker compose file I got an error, then I fixed the file as below:
    version: '3'
    services:
    mongo:
    image: mongo
    ports:
    - 27017:27017
    environment:
    - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
    - ME_CONFIG_MONGODB_ADMINPASSWORD=admin
    mongo-express:
    image: mongo-express
    restart: always
    links:
    - mongo
    ports:
    - 8080:8081
    environment:
    - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
    - ME_CONFIG_MONGODB_ADMINPASSWORD=admin

  • @scottamolinari
    @scottamolinari Před 2 lety

    @TechWorld with Nana - What is your take on using compose files for setting up k8s?

  • @5chmts
    @5chmts Před 2 lety

    I absolutely love your tutorials, Nana. I've come into a problem though, where mongo spews out logs in plain text which is very difficult to read. Any idea on how to overcome that? Thanks in advance!

    • @5chmts
      @5chmts Před 2 lety

      Nevermind, just tried a couple of different versions and 4.2 did me good. :)

  • @Techonsapevole
    @Techonsapevole Před 4 lety

    Great video, thanks.
    Do you have a reccomanded way to backup data and db containers?

    • @TechWorldwithNana
      @TechWorldwithNana  Před 4 lety

      Yes there is a standard way to backup data using "docker volumes". I will be covering "docker volumes" in the next videos, since it's an important concept.
      Simply explained, it is a physical storage on your host that is used by docker container to persist its data.

    • @Techonsapevole
      @Techonsapevole Před 4 lety

      @@TechWorldwithNana Thanks, what about databases? Is possible to do something for nonstatic data?

    • @TechWorldwithNana
      @TechWorldwithNana  Před 4 lety

      @@Techonsapevole yes, exactly. volumes are used for databases and other stateful applications to persist the data. So when you restart the database container the data will still be there.
      Do you have a specific use case?

    • @Techonsapevole
      @Techonsapevole Před 4 lety

      @@TechWorldwithNana i mean, all the db containers should be stopped before the backup and then unfreezed to have consistent data.. Is there a docker way to do it in a safe way?

    • @TechWorldwithNana
      @TechWorldwithNana  Před 4 lety +2

      @@Techonsapevole Yes. You can do data backups and restores with docker volumes as well.
      One way to backup and restore will be to create docker volume backups or tar archive of the volume contents. For this you will need to stop the container. And create a new one that will create this artefact using tar command.
      Similarly you can restore this docker volume archive in a new container.
      However if you don't want to start all the containers for a backup, a better way will be to do the automated dumps, specifically for SQL database you will create mysql dump from a running container.
      Using “docker exec …” command you can execute sqldump and save that dump file on your host.
      When restoring you can again using “docker exec …” command play the dump into the container.
      And of course both ways of backup and restore of data can be fully automated.

  • @_______6398
    @_______6398 Před 2 lety +1

    Hi Nana,
    Thanks for the awesome vid. I have a pretty specific question. What is the best standard to follow for the given situation:
    - I have a dockerfile in one GitHub repo
    - 2nd dockerfile in another GitHub repo
    What’s the best practice to follow when I want both of these remote dockerfiles to be included in the same yaml but want to not just spin up both containers thru docker-compose yaml, but also rebuild each remote dockerfile with using the latest code base from each dockerfile’s respective remote repo.
    Locally, I understand this can be done using: docker-compose up - - build
    But how can I achieve this to only rebuild each individual image from their respective remote GitHub repo dockerfile based on the REMOTE GitHub repos code base?
    I know that’s a lot but would really appreciate your input! Keep up these videos btw super helpful 😁 thanks!

    • @cosmos4427
      @cosmos4427 Před 2 lety

      1.You can create a GitHub action workflow in any one of the two repos,
      2.clone both repos in that action,
      3. then you can use docker build action to build two images from your two repos and tag them as latest always,also push them if you have a container registry.
      4.Then specify the same images in compose file with version latest. And spin them up to your vm.

  • @paraskh007
    @paraskh007 Před 4 lety +1

    How to add "wait" logic in compose?
    Hi Nana. You mentioned in video about we can add wait logic if there are multiple containers and dependency. Can you please explain it in detail or with an example?
    Thanking you in advance for such simple way explaining complex things.

  • @vijayaj2024
    @vijayaj2024 Před 4 lety +1

    Excellent videos. Will you be also doing something similar for Kubernetes?

  • @antoniopafundi3455
    @antoniopafundi3455 Před 3 lety +1

    I have an error in build: mongo is looking for an image in my local directory instead that in docker hub

  • @davidoh6342
    @davidoh6342 Před 2 lety

    You have to show us how you set up the collection for users so that we can follow through everythinggggg

  • @priyankverma7434
    @priyankverma7434 Před 6 měsíci

    Can you please update the video to show the use with Docker Compose version 3.1? I got so many errors and finally made it work by finally going through certain documentations and other stuff.

  • @Santiago-yy3jg
    @Santiago-yy3jg Před 2 lety

    Hi Nana, i have a question. Why is it forwarding to port 8081? As you said in the yaml file it it 8080:8080.

  • @myrachoantonio8832
    @myrachoantonio8832 Před 3 lety

    hey thank you for the tutorial but i have an issue i was working on my docker compose file with go, mysql, phpmyadmin. after docker up commad the phpmyadmin could connect to mysql db.then i used the mysql container name- phpmyqdminb connected but my app would still not connect. what do i need to do? i Used mysql port before and even the phpmyadmin could not connect to the mysql db then

  • @aram5642
    @aram5642 Před 3 lety

    I have been playing with Docker for past two weeks and I must say I still feel very confused as to the correct development drill. Should I use docker build or docker-compose build or docker-compose --build up, every time I make a change to package.json (modify a script) or Dockerfile itself.

  • @jaggyjut
    @jaggyjut Před 2 lety

    The mongo-express container stops running during the initial run and needs to be manually started. I think mongo-express needs start needs to be delayed to ensure mongodb container is up first.

  • @BambaZillah
    @BambaZillah Před 2 lety

    What is "context" in a docker compose?
    I get an issue with a copy command saying the file isn't there while it is. Lets say in ./schema.sql
    Context is set to .
    Cant up compose it says rpc error, file not found. Can you please help?

  • @lazyproton
    @lazyproton Před rokem

    💕

  • @vinayakpatil240
    @vinayakpatil240 Před rokem

    From where did you launched this windows?

  • @squalazzo
    @squalazzo Před 3 lety

    from where does it take the name for the network? thanks

  • @diegovallante51
    @diegovallante51 Před 2 lety

    147 / 5.000
    Risultati della traduzione
    Hello,
    I did not understand how to set up the volumes for the docker-compose.yml, could you indicate where to study them?
    thank you very much for your videos.

  • @mohitsharma-ew4tj
    @mohitsharma-ew4tj Před 4 lety +1

    please explain networks

  • @muaazster
    @muaazster Před 2 lety

    How do we run , docker-compose in windows , even i created yaml file , says couldnt find

  • @jvm-tv
    @jvm-tv Před 3 lety

    Who else is binge watching Nana's Docker series?

  • @uploadvoice
    @uploadvoice Před 2 lety +1

    here we don't need to specify the port mapping for mongo, I don't see why we map it, between containers in same network, there is no need ....

  • @alivecoding4995
    @alivecoding4995 Před rokem

    I thoughts lists need to be using "-"? Why aren't there dashes before "mongo" and "mongo express" then?

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

    I could not view the network created so I did docker network ls

  • @musaisgenderli2715
    @musaisgenderli2715 Před 3 lety

    I have faced with this problem:
    ERROR: In file '.\mongo.yaml', service 'ports' must be a mapping not an array.
    what can i do?

  • @kixanity
    @kixanity Před 3 lety

    12:24 battery change from 99 to 100

  • @yolamontalvan9502
    @yolamontalvan9502 Před rokem

    Did you changed your voice?

  • @brianshanahan3878
    @brianshanahan3878 Před 4 lety +1

    SORRY!!! I went back one video and found the Gitlab link.. ;)

    • @fuffsec
      @fuffsec Před 3 lety

      gitlab.com/nanuchi/techworld-js-docker-demo-app

  • @nvinodan310
    @nvinodan310 Před 2 lety

    what's your height?