title
Docker Compose Tutorial
description
Learn all about Docker Compose so you can orchestrate your services with confidence!
- Get the complete Docker course (zero to hero): https://bit.ly/3sO7Z5H
- Subscribe for more Docker tutorials like this: https://goo.gl/6PYaGF
⭐️ Want to learn more from me? Check out these links:
Courses: https://codewithmosh.com
Twitter: https://twitter.com/moshhamedani
Facebook: https://www.facebook.com/programmingwithmosh/
Blog: http://programmingwithmosh.com
#Docker #DevOps
Docker is the de facto standard for building, shipping and running applications in a consistent manner. That's why most companies use it and are looking for developers with Docker skills. If you're looking for a career in software or DevOps engineering, you must have Docker on your resume. And not only that, you should know it well and be able to use it to effectively package and deploy your applications.
detail
{'title': 'Docker Compose Tutorial', 'heatmap': [{'end': 462.346, 'start': 435.447, 'weight': 0.845}, {'end': 972.395, 'start': 951.076, 'weight': 0.741}, {'end': 1229.198, 'start': 1205.604, 'weight': 0.751}, {'end': 1351.275, 'start': 1288.557, 'weight': 0.789}, {'end': 1409.134, 'start': 1385.306, 'weight': 1}], 'summary': "Tutorial 'docker compose tutorial' covers building multi-container applications with docker compose, simplifying application setup, json and yaml formats, creation of docker compose file, configuration and syntax, and networking in docker, providing practical examples and demonstrations.", 'chapters': [{'end': 161.911, 'segs': [{'end': 89.055, 'src': 'embed', 'start': 40.141, 'weight': 0, 'content': [{'end': 45.245, 'text': 'A front-end built with React, a back-end built with Node, and a MongoDB database.', 'start': 40.141, 'duration': 5.104}, {'end': 48.887, 'text': "Once again, you don't need to be familiar or use any of these tools.", 'start': 45.725, 'duration': 3.162}, {'end': 52.209, 'text': 'Our focus here is on Docker and not on development tools.', 'start': 49.127, 'duration': 3.082}, {'end': 56.873, 'text': 'I think this is the most exciting part of this course where you can see everything coming together.', 'start': 52.789, 'duration': 4.084}, {'end': 61.537, 'text': "We'll talk about Docker Compose for building and running multi container applications.", 'start': 57.293, 'duration': 4.244}, {'end': 66.881, 'text': "We'll also talk about Docker networking, database migration, and running automated tests.", 'start': 61.957, 'duration': 4.924}, {'end': 69.163, 'text': "So, let's jump in and get started.", 'start': 67.301, 'duration': 1.862}, {'end': 84.933, 'text': "In this section we're going to use a tool called docker compose, which is built on top of docker engine.", 'start': 80.29, 'duration': 4.643}, {'end': 89.055, 'text': 'It makes it incredibly easy to start applications with multiple containers.', 'start': 85.413, 'duration': 3.642}], 'summary': 'Course focuses on docker compose for multi-container applications, docker networking, database migration, and running automated tests.', 'duration': 48.914, 'max_score': 40.141, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA40141.jpg'}, {'end': 141.926, 'src': 'embed', 'start': 112.155, 'weight': 2, 'content': [{'end': 117.541, 'text': 'To verify it, just go to the terminal window and type docker compose dash dash version.', 'start': 112.155, 'duration': 5.386}, {'end': 123.201, 'text': "So I'm running docker compose version 1.28.5.", 'start': 118.86, 'duration': 4.341}, {'end': 125.702, 'text': 'Make sure your version is the same or newer.', 'start': 123.201, 'duration': 2.501}, {'end': 130.363, 'text': "If you're using an older version, again, google upgrade docker compose.", 'start': 126.262, 'duration': 4.101}, {'end': 133.404, 'text': 'Or you might just install the latest version of docker.', 'start': 130.842, 'duration': 2.562}, {'end': 135.604, 'text': 'Now, back to this page.', 'start': 134.244, 'duration': 1.36}, {'end': 141.926, 'text': "If you're using windows server or linux, there are specific instructions you have to follow to install docker compose.", 'start': 136.164, 'duration': 5.762}], 'summary': 'Verify docker compose version 1.28.5 or newer, follow specific instructions for windows server or linux.', 'duration': 29.771, 'max_score': 112.155, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA112155.jpg'}], 'start': 1.127, 'title': 'Docker compose for multi-container apps', 'summary': 'Introduces docker compose for building multi-container applications, including a real-world application with front-end (react), back-end (node), and mongodb. it also covers installation and version verification.', 'chapters': [{'end': 161.911, 'start': 1.127, 'title': 'Docker compose: building multi-container applications', 'summary': 'Introduces docker compose and its features for building and running multi-container applications, including a real-world application with three building blocks: a front-end built with react, a back-end built with node, and a mongodb database. it also covers docker compose installation and version verification.', 'duration': 160.784, 'highlights': ['The chapter introduces Docker Compose and its features for building and running multi-container applications. The section covers the use of Docker Compose for running multi-container applications, including a real-world application with three building blocks: a front-end built with React, a back-end built with Node, and a MongoDB database.', "It also covers Docker Compose installation and version verification. The video provides instructions on Docker Compose installation, including verifying the version using the 'docker compose --version' command."]}], 'duration': 160.784, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1127.jpg', 'highlights': ['The chapter introduces Docker Compose and its features for building and running multi-container applications.', 'The section covers the use of Docker Compose for running multi-container applications, including a real-world application with three building blocks: a front-end built with React, a back-end built with Node, and a MongoDB database.', 'It also covers Docker Compose installation and version verification.', "The video provides instructions on Docker Compose installation, including verifying the version using the 'docker compose --version' command."]}, {'end': 511.032, 'segs': [{'end': 202.487, 'src': 'embed', 'start': 162.271, 'weight': 1, 'content': [{'end': 164.273, 'text': "They're getting in the way, I want to get rid of them all.", 'start': 162.271, 'duration': 2.002}, {'end': 170.518, 'text': 'How do we do this? Well, you know that we can remove images using docker image remove command.', 'start': 165.053, 'duration': 5.465}, {'end': 173.461, 'text': 'And here we can type one or more image ids.', 'start': 170.818, 'duration': 2.643}, {'end': 177.804, 'text': 'Now, how can we get all image ids and pass them here? Let me show you a cool trick.', 'start': 174.041, 'duration': 3.763}, {'end': 187.233, 'text': 'So we can run docker image ls We see all the images, right? But if we pass dash q at the end, we only get image ids.', 'start': 178.485, 'duration': 8.748}, {'end': 191.477, 'text': 'Now we can pass this as an argument to docker image remove.', 'start': 187.953, 'duration': 3.524}, {'end': 199.404, 'text': 'So, docker image remove, now here we add a dollar sign, and in parenthesis, we type that other command.', 'start': 191.777, 'duration': 7.627}, {'end': 202.487, 'text': 'So docker image ls dash q.', 'start': 199.624, 'duration': 2.863}], 'summary': "Removing docker images using 'docker image remove' command, and obtaining image ids using 'docker image ls -q'.", 'duration': 40.216, 'max_score': 162.271, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA162271.jpg'}, {'end': 462.346, 'src': 'heatmap', 'start': 428.421, 'weight': 0, 'content': [{'end': 435.226, 'text': 'if you look here, we have a file called docker compose, which is used for composing a multi container application.', 'start': 428.421, 'duration': 6.805}, {'end': 437.168, 'text': 'We are going to talk about that in detail soon.', 'start': 435.447, 'duration': 1.721}, {'end': 443.313, 'text': 'Now, once we have this file in our project, we can simply run docker compose up.', 'start': 437.848, 'duration': 5.465}, {'end': 445.606, 'text': "that's all we have to do.", 'start': 444.605, 'duration': 1.001}, {'end': 453.355, 'text': "Now docker is automatically downloading this particular version of MongoDB, so it's downloading all these layers.", 'start': 446.427, 'duration': 6.928}, {'end': 458.561, 'text': "then, at the same time, it's going to install all the dependencies for our frontend and backend projects.", 'start': 453.355, 'duration': 5.206}, {'end': 462.346, 'text': 'it will start web servers and run automated tests, all in this window.', 'start': 458.561, 'duration': 3.785}], 'summary': 'Using docker compose to run a multi-container app, automating mongodb download and dependencies installation.', 'duration': 24.934, 'max_score': 428.421, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA428421.jpg'}, {'end': 515.174, 'src': 'embed', 'start': 489.662, 'weight': 3, 'content': [{'end': 498.086, 'text': 'So we have a migration script for populating our database and docker automatically executed our migration script as part of bringing up this application.', 'start': 489.662, 'duration': 8.424}, {'end': 500.687, 'text': 'This is a very common real world scenario.', 'start': 498.566, 'duration': 2.121}, {'end': 507.87, 'text': 'Now here we can add new movies, movie 1, movie 2, whatever, and we can also delete these movies.', 'start': 501.268, 'duration': 6.602}, {'end': 511.032, 'text': 'So we brought up this application using a single command.', 'start': 508.551, 'duration': 2.481}, {'end': 515.174, 'text': 'Now I briefly mentioned this file, docker-compose.yaml.', 'start': 511.992, 'duration': 3.182}], 'summary': 'Database migration script executed in docker for new movies, demonstrating simple application setup.', 'duration': 25.512, 'max_score': 489.662, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA489662.jpg'}], 'start': 162.271, 'title': 'Docker simplifying application setup', 'summary': "Discusses removing docker images and containers, and demonstrates how to remove all images and containers using commands and shortcuts. it also highlights the use of 'docker image ls -q' and 'docker container ls -a' to obtain image and container ids. additionally, it demonstrates how docker simplifies setting up a multi-container application by eliminating the need for manual installation of dependencies, database setup, and running multiple commands, resulting in a single command setup, saving time and effort while automatically populating the database with movies.", 'chapters': [{'end': 345.012, 'start': 162.271, 'title': 'Removing docker images and containers', 'summary': "Discusses removing docker images and containers, demonstrating how to remove all images and containers using commands and shortcuts, and highlighting the use of 'docker image ls -q' and 'docker container ls -a' to obtain image and container ids.", 'duration': 182.741, 'highlights': ["By using 'docker image ls -q', only image ids can be obtained, allowing for easy removal of all images with 'docker image remove'.", "The technique of obtaining all container ids using 'docker container ls -a' and removing them all in one go is demonstrated.", 'The shortcut for removing everything in Docker, including images, containers, and volumes, by clicking on the docker icon and accessing the troubleshoot utilities is explained.']}, {'end': 511.032, 'start': 345.472, 'title': 'Docker simplifies application setup', 'summary': 'Demonstrates how docker simplifies setting up a multi-container application by eliminating the need for manual installation of dependencies, database setup, and running multiple commands, resulting in a single command setup, saving time and effort while automatically populating the database with movies.', 'duration': 165.56, 'highlights': ["Docker eliminates the need for multiple manual steps by enabling a single command setup for the multi-container application, saving time and effort. By running 'docker-compose up', Docker automatically handles downloading MongoDB, installing dependencies, starting web servers, and running automated tests.", 'Docker automatically populates the database with movies as part of bringing up the application, showcasing its capability in real-world scenarios. The migration script for populating the database is executed by Docker as part of bringing up the application, demonstrating a common real-world scenario without the need for manual intervention.', 'Setting up the application without Docker requires manual installation of dependencies, running web servers, and executing migration scripts, involving multiple terminal windows and additional steps. Setting up the application outside of Docker involves numerous manual steps, including installing dependencies, starting web servers, and executing migration scripts, requiring multiple terminal windows and additional installations such as MongoDB.']}], 'duration': 348.761, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA162271.jpg', 'highlights': ['Docker simplifies setting up a multi-container application, eliminating manual steps and saving time and effort.', "Using 'docker image ls -q' allows for easy removal of all images with 'docker image remove'.", "Obtaining all container ids using 'docker container ls -a' and removing them all in one go is demonstrated.", 'Docker automatically populates the database with movies as part of bringing up the application, showcasing its capability in real-world scenarios.']}, {'end': 773.279, 'segs': [{'end': 564.702, 'src': 'embed', 'start': 538.167, 'weight': 0, 'content': [{'end': 542.872, 'text': "So, in the root of this project, we're going to add a new file called data.json.", 'start': 538.167, 'duration': 4.705}, {'end': 549.178, 'text': ".json, as you probably know, is a language, it's a human readable language for representing data.", 'start': 544.133, 'duration': 5.045}, {'end': 554.679, 'text': "So in this json file we can have an object or an array, let's say we want to represent a course.", 'start': 549.838, 'duration': 4.841}, {'end': 557.82, 'text': 'A course can have properties like name, price, and so on.', 'start': 555.18, 'duration': 2.64}, {'end': 561.801, 'text': 'So in this object we can add one or more key value pairs.', 'start': 558.5, 'duration': 3.301}, {'end': 564.702, 'text': 'Our keys should always be surrounded in double quotes.', 'start': 562.381, 'duration': 2.321}], 'summary': 'Adding a data.json file with object or array to represent a course, with properties like name and price.', 'duration': 26.535, 'max_score': 538.167, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA538167.jpg'}, {'end': 773.279, 'src': 'embed', 'start': 736.654, 'weight': 1, 'content': [{'end': 739.755, 'text': 'As you can see, yaml is easier to read and understand.', 'start': 736.654, 'duration': 3.101}, {'end': 747.128, 'text': "Now, why don't we use yaml all the time? Well, because parsing yaml files is a little bit slower than parsing JSON files.", 'start': 740.255, 'duration': 6.873}, {'end': 750.989, 'text': "Because the parser doesn't know if this is a string or a number.", 'start': 747.668, 'duration': 3.321}, {'end': 754.61, 'text': 'So it has to read everything as a string and then try to evaluate it.', 'start': 751.469, 'duration': 3.141}, {'end': 761.012, 'text': 'In contrast, in JSON, strings are represented using quotes, and more specifically double quotes.', 'start': 755.29, 'duration': 5.722}, {'end': 764.593, 'text': "So the parser knows that this is a string and it shouldn't evaluate it.", 'start': 761.312, 'duration': 3.281}, {'end': 773.279, 'text': 'okay? So quite often we use yaml files for configuration files, and json for exchanging data between multiple computers, like a client and a server.', 'start': 764.853, 'duration': 8.426}], 'summary': 'Yaml is easier to read, but json is faster for parsing and exchanging data between computers.', 'duration': 36.625, 'max_score': 736.654, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA736654.jpg'}], 'start': 511.992, 'title': 'Json and yaml formats', 'summary': "Covers the basics of json and yaml formats, including the creation of a data.json file with key-value pairs for representing a course, and explains the differences between json and yaml, highlighting yaml's less clutter, use of indentation for hierarchy representation, absence of quotes and commas, and preference for json in data exchange.", 'chapters': [{'end': 609.105, 'start': 511.992, 'title': 'Introduction to json and yaml formats', 'summary': 'Covers the basics of json and yaml formats, including the creation of a data.json file with key-value pairs for representing a course, and the syntax rules for each data type.', 'duration': 97.113, 'highlights': ['The chapter covers the basics of JSON and YAML formats It includes an introduction to the yaml format and the creation of a data.json file.', 'Creation of a data.json file with key-value pairs Demonstrates the process of defining key-value pairs in a data.json file, including the use of strings, numbers, booleans, and arrays.', 'Syntax rules for each data type Explains the syntax rules, such as using double quotes for keys, for each data type including strings, numbers, booleans, and arrays.']}, {'end': 773.279, 'start': 609.625, 'title': 'Json vs yaml for data presentation', 'summary': "Explains how to convert a json file to yaml, highlighting the differences, such as yaml's less clutter, use of indentation for hierarchy representation, absence of quotes and commas, and preference for json in data exchange.", 'duration': 163.654, 'highlights': ['YAML is easier to read and understand compared to JSON, as it has less clutter and uses indentation for hierarchy representation.', 'YAML does not use quotes or commas to separate key value pairs, and uses hyphens to represent lists or arrays, making it more concise.', 'JSON is preferred for data exchange between multiple computers due to its explicit representation of strings using quotes, enabling faster parsing compared to YAML.']}], 'duration': 261.287, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA511992.jpg', 'highlights': ['Creation of a data.json file with key-value pairs Demonstrates the process of defining key-value pairs in a data.json file, including the use of strings, numbers, booleans, and arrays.', 'YAML is easier to read and understand compared to JSON, as it has less clutter and uses indentation for hierarchy representation.', 'JSON is preferred for data exchange between multiple computers due to its explicit representation of strings using quotes, enabling faster parsing compared to YAML.']}, {'end': 1006.721, 'segs': [{'end': 848.939, 'src': 'embed', 'start': 825.187, 'weight': 0, 'content': [{'end': 832.211, 'text': 'On this page you can see various compose file formats and their compatibility with docker engine.', 'start': 825.187, 'duration': 7.024}, {'end': 839.594, 'text': 'We are using the latest version of docker engine, so I want to use the latest compose file format so we have access to the latest features.', 'start': 832.791, 'duration': 6.803}, {'end': 843.316, 'text': "So, we're going to set this to 3.8.", 'start': 840.195, 'duration': 3.121}, {'end': 848.939, 'text': 'Now, here we need to wrap this number with double quotes, otherwise it will be evaluated as a number.', 'start': 843.316, 'duration': 5.623}], 'summary': 'Using docker engine 3.8 for latest features.', 'duration': 23.752, 'max_score': 825.187, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA825187.jpg'}, {'end': 901.616, 'src': 'embed', 'start': 871.314, 'weight': 1, 'content': [{'end': 874.976, 'text': 'Now your application might have other moving parts, so you can define them here.', 'start': 871.314, 'duration': 3.662}, {'end': 878.623, 'text': 'Now, these names are arbitrary, so we can call them anything.', 'start': 875.777, 'duration': 2.846}, {'end': 885.116, 'text': 'We can change this to db, we can change the backend to api, and the frontend to web.', 'start': 878.783, 'duration': 6.333}, {'end': 894.168, 'text': "The idea here is that we're defining various services and telling docker how to build images for each service and how to run these images.", 'start': 886.44, 'duration': 7.728}, {'end': 901.616, 'text': "So here we're going to have properties and the value of these properties will eventually be used when running our containers.", 'start': 894.869, 'duration': 6.747}], 'summary': "Defining various services in docker for application's moving parts.", 'duration': 30.302, 'max_score': 871.314, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA871314.jpg'}, {'end': 950.355, 'src': 'embed', 'start': 919.717, 'weight': 2, 'content': [{'end': 921.82, 'text': "So we don't have to manually start our containers.", 'start': 919.717, 'duration': 2.103}, {'end': 925.704, 'text': 'Docker compose will take care of starting our containers under the hood.', 'start': 922.4, 'duration': 3.304}, {'end': 931.427, 'text': 'So for each service, we need to tell docker how to build an image for that service.', 'start': 926.965, 'duration': 4.462}, {'end': 937.248, 'text': 'So here we can use the build property and tell docker compose where it can find a docker file.', 'start': 932.067, 'duration': 5.181}, {'end': 945.391, 'text': 'So if you look at this project, you can see that in our backend and frontend folders, we have a docker file.', 'start': 937.968, 'duration': 7.423}, {'end': 950.355, 'text': 'this docker file is almost identical to the one we created in the previous section.', 'start': 946.511, 'duration': 3.844}], 'summary': 'Docker compose automates container start-up, using build property for image construction.', 'duration': 30.638, 'max_score': 919.717, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA919717.jpg'}, {'end': 973.736, 'src': 'heatmap', 'start': 951.076, 'weight': 0.741, 'content': [{'end': 958.643, 'text': 'So we start from a node image, we create a user, we set our working directory, copy all the files and install the dependencies,', 'start': 951.076, 'duration': 7.567}, {'end': 962.627, 'text': 'then expose port 3001 and start the web server.', 'start': 958.643, 'duration': 3.984}, {'end': 966.23, 'text': 'We have a similar docker file in our front end project.', 'start': 963.348, 'duration': 2.882}, {'end': 967.251, 'text': "Let's have a quick look.", 'start': 966.511, 'duration': 0.74}, {'end': 972.395, 'text': "So that was the backend, here's the frontend, and here we have a docker file.", 'start': 968.072, 'duration': 4.323}, {'end': 973.736, 'text': 'Almost identical.', 'start': 972.835, 'duration': 0.901}], 'summary': 'Creating user, setting working directory, installing dependencies, and starting web server in backend and frontend docker files.', 'duration': 22.66, 'max_score': 951.076, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA951076.jpg'}], 'start': 773.96, 'title': 'Creating docker compose file', 'summary': "Provides a detailed guide on creating a docker compose file from scratch, covering setting the version to 3.8, defining services such as frontend, backend, and database, and specifying image building for each service using the 'build' property.", 'chapters': [{'end': 1006.721, 'start': 773.96, 'title': 'Creating docker compose file', 'summary': "Explains how to create a docker-compose file from scratch, including setting the version to 3.8 for the latest features, defining services like frontend, backend, and database, and specifying how to build images for each service using the 'build' property.", 'duration': 232.761, 'highlights': ['Setting the version to 3.8 for the latest features The chapter emphasizes setting the version to 3.8 to access the latest features of docker engine.', 'Defining services like frontend, backend, and database It explains the process of defining various services such as frontend, backend, and database within the docker-compose file.', "Specifying how to build images for each service using the 'build' property The transcript details the process of specifying how to build images for each service using the 'build' property within the docker-compose file."]}], 'duration': 232.761, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA773960.jpg', 'highlights': ['Setting the version to 3.8 for the latest features', 'Defining services like frontend, backend, and database', "Specifying how to build images for each service using the 'build' property"]}, {'end': 1393.391, 'segs': [{'end': 1038.692, 'src': 'embed', 'start': 1007.381, 'weight': 0, 'content': [{'end': 1010.603, 'text': "So instead of the build property, we're going to use the image property.", 'start': 1007.381, 'duration': 3.222}, {'end': 1016.867, 'text': "Now for this application, I'm going to use Mongo version 4.0- Xenio.", 'start': 1011.403, 'duration': 5.464}, {'end': 1023.07, 'text': 'So that is Mongo version 4 built on top of Xenio, which is Ubuntu version 16.', 'start': 1017.067, 'duration': 6.003}, {'end': 1031.122, 'text': 'If you look at docker hub, you can see that Mongo also has images built on top of Windows, but Windows images are very large, over 2 gigabytes.', 'start': 1023.07, 'duration': 8.052}, {'end': 1034.086, 'text': "So that's why I prefer to use Linux images.", 'start': 1031.602, 'duration': 2.484}, {'end': 1038.692, 'text': 'So for any of these services, we can either build an image or pull it down.', 'start': 1034.767, 'duration': 3.925}], 'summary': 'Using mongo version 4.0-xenio on ubuntu 16 for lightweight image, avoiding large windows images.', 'duration': 31.311, 'max_score': 1007.381, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1007381.jpg'}, {'end': 1086.659, 'src': 'embed', 'start': 1051.897, 'weight': 1, 'content': [{'end': 1061.279, 'text': 'So our front end application starts on port 3000, so I want to map port 3000 of the host to port 3000 of the container running this image.', 'start': 1051.897, 'duration': 9.382}, {'end': 1070.751, 'text': "Now similarly for our API, we're going to define a port mapping, this one is going to be 3001 to 3001.", 'start': 1061.899, 'duration': 8.852}, {'end': 1086.659, 'text': 'Now, MongoDB by default listens on port 27017, so I want to map the same port so we can access MongoDB using a MongoDB client like MongoDB Compass.', 'start': 1070.751, 'duration': 15.908}], 'summary': 'Mapping ports: 3000 to 3000, 3001 to 3001, and 27017 for mongodb.', 'duration': 34.762, 'max_score': 1051.897, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1051897.jpg'}, {'end': 1140.195, 'src': 'embed', 'start': 1111.334, 'weight': 2, 'content': [{'end': 1115.475, 'text': "Now, a lot of these are for really special cases, so you don't need to use them all the time,", 'start': 1111.334, 'duration': 4.141}, {'end': 1118.776, 'text': 'but the ones that we use most of the time are build or image.', 'start': 1115.475, 'duration': 3.301}, {'end': 1121.957, 'text': 'you also use ports, volumes, environment and so on.', 'start': 1118.776, 'duration': 3.181}, {'end': 1128.743, 'text': 'So our api project needs an environment variable that tells where our database is.', 'start': 1122.717, 'duration': 6.026}, {'end': 1132.607, 'text': 'so here we set environment now.', 'start': 1128.743, 'duration': 3.864}, {'end': 1136.972, 'text': 'here we can use the list syntax because we can have multiple environment variables.', 'start': 1132.607, 'duration': 4.365}, {'end': 1140.195, 'text': 'so we said db underline, url 2.', 'start': 1136.972, 'duration': 3.223}], 'summary': 'Main dockerfile options include build, image, ports, volumes, and environment. api project requires environment variable for database location.', 'duration': 28.861, 'max_score': 1111.334, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1111334.jpg'}, {'end': 1229.198, 'src': 'heatmap', 'start': 1205.604, 'weight': 0.751, 'content': [{'end': 1213.79, 'text': "The last thing we want out here is a volume, because we don't want MongoDB to rate data to the temporary file system of the container.", 'start': 1205.604, 'duration': 8.186}, {'end': 1222.994, 'text': 'So here we set volumes and again we can have one or more volume mappings.', 'start': 1213.79, 'duration': 9.204}, {'end': 1224.595, 'text': 'so we add a hyphen.', 'start': 1222.994, 'duration': 1.601}, {'end': 1229.198, 'text': "we're going to map a volume called Vidly and of course we can call it anything.", 'start': 1224.595, 'duration': 4.603}], 'summary': 'Avoiding volume for mongodb to prevent data rate to temporary file system of the container.', 'duration': 23.594, 'max_score': 1205.604, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1205604.jpg'}, {'end': 1274.557, 'src': 'embed', 'start': 1251.809, 'weight': 3, 'content': [{'end': 1259.352, 'text': 'So we want to map this volume to this directory, so whatever that is written inside this directory is actually outside of this container.', 'start': 1251.809, 'duration': 7.543}, {'end': 1261.453, 'text': "It's somewhere else in our volume.", 'start': 1259.772, 'duration': 1.681}, {'end': 1267.132, 'text': 'Now because we have used this volume here, we have to define it in our compose file.', 'start': 1263.43, 'duration': 3.702}, {'end': 1274.557, 'text': 'So we press enter, remove all the annotations, so now we are at the same level as services.', 'start': 1267.693, 'duration': 6.864}], 'summary': 'Mapping a volume to a directory outside the container in a compose file.', 'duration': 22.748, 'max_score': 1251.809, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1251809.jpg'}, {'end': 1351.275, 'src': 'heatmap', 'start': 1288.557, 'weight': 0.789, 'content': [{'end': 1291.819, 'text': 'We just have to define the volume first before we can use it.', 'start': 1288.557, 'duration': 3.262}, {'end': 1299.581, 'text': 'So this is our compose file, now we can make this more readable by adding line breaks in between these properties.', 'start': 1292.559, 'duration': 7.022}, {'end': 1306.33, 'text': "We can also order these services any way we want, so currently I'm ordering them from front to back.", 'start': 1300.642, 'duration': 5.688}, {'end': 1311.598, 'text': "we can also order them from back to front, so we'll put database first, then api and then web.", 'start': 1306.33, 'duration': 5.268}, {'end': 1315.944, 'text': "So we're done with our compose file, next I'm going to show you how to build the images.", 'start': 1312.399, 'duration': 3.545}, {'end': 1327.312, 'text': 'Earlier I told you that docker compose is built on top of docker engine.', 'start': 1323.208, 'duration': 4.104}, {'end': 1333.837, 'text': 'So everything we have done with docker engine, like building images, listing them, starting containers and so on.', 'start': 1327.772, 'duration': 6.065}, {'end': 1337.24, 'text': 'all of these operations are also available using docker compose.', 'start': 1333.837, 'duration': 3.403}, {'end': 1337.981, 'text': 'Let me show you.', 'start': 1337.501, 'duration': 0.48}, {'end': 1342.065, 'text': 'So we type docker compose without any arguments.', 'start': 1338.581, 'duration': 3.484}, {'end': 1351.275, 'text': 'enter, look, We have all these sub commands like we have rm for removing stopped containers, we have run, we have push pull and so on.', 'start': 1342.065, 'duration': 9.21}], 'summary': 'Defining volume, ordering services, and using docker compose commands.', 'duration': 62.718, 'max_score': 1288.557, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1288557.jpg'}, {'end': 1351.275, 'src': 'embed', 'start': 1300.642, 'weight': 4, 'content': [{'end': 1306.33, 'text': "We can also order these services any way we want, so currently I'm ordering them from front to back.", 'start': 1300.642, 'duration': 5.688}, {'end': 1311.598, 'text': "we can also order them from back to front, so we'll put database first, then api and then web.", 'start': 1306.33, 'duration': 5.268}, {'end': 1315.944, 'text': "So we're done with our compose file, next I'm going to show you how to build the images.", 'start': 1312.399, 'duration': 3.545}, {'end': 1327.312, 'text': 'Earlier I told you that docker compose is built on top of docker engine.', 'start': 1323.208, 'duration': 4.104}, {'end': 1333.837, 'text': 'So everything we have done with docker engine, like building images, listing them, starting containers and so on.', 'start': 1327.772, 'duration': 6.065}, {'end': 1337.24, 'text': 'all of these operations are also available using docker compose.', 'start': 1333.837, 'duration': 3.403}, {'end': 1337.981, 'text': 'Let me show you.', 'start': 1337.501, 'duration': 0.48}, {'end': 1342.065, 'text': 'So we type docker compose without any arguments.', 'start': 1338.581, 'duration': 3.484}, {'end': 1351.275, 'text': 'enter, look, We have all these sub commands like we have rm for removing stopped containers, we have run, we have push pull and so on.', 'start': 1342.065, 'duration': 9.21}], 'summary': 'Demonstrating ordering and operations in docker compose.', 'duration': 50.633, 'max_score': 1300.642, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1300642.jpg'}], 'start': 1007.381, 'title': 'Docker compose configuration and syntax', 'summary': 'Discusses configuring docker compose for an application, utilizing mongodb version 4.0-xenio image on linux, defining port mappings and environment variables for the api project. it also covers the syntax and usage of volumes in docker compose, emphasizing the need to define and use volumes properly and the availability of various subcommands for managing the application as a whole.', 'chapters': [{'end': 1195.416, 'start': 1007.381, 'title': 'Docker compose configuration', 'summary': 'Discusses configuring docker compose for an application, utilizing mongodb version 4.0-xenio image, emphasizing the preference for linux images due to smaller size, and defining port mappings and environment variables for the api project.', 'duration': 188.035, 'highlights': ['Mongo version 4 built on top of Xenio, which is Ubuntu version 16, is preferred due to smaller size compared to Windows images of over 2 gigabytes The Mongo version 4 image built on Xenio, Ubuntu version 16, is favored over Windows images due to their large size of over 2 gigabytes.', 'Defining port mappings for the front end and API applications to map the host ports to container ports, such as mapping port 3000 to 3000 for the front end and 3001 to 3001 for the API Port mappings are defined for the front end and API applications, mapping specific host ports to corresponding container ports, such as 3000 to 3000 for the front end and 3001 to 3001 for the API.', 'Environment variables are set for the API project, including defining a MongoDB connection string, specifying the database location with the db_url property Environment variables are configured for the API project, including setting a MongoDB connection string and specifying the database location using the db_url property.']}, {'end': 1393.391, 'start': 1196.176, 'title': 'Docker compose syntax and volumes', 'summary': 'Covers the syntax and usage of volumes in docker compose, including defining volume mappings, ordering services, and building images, with emphasis on the need to define and use volumes properly and the availability of various subcommands for managing the application as a whole.', 'duration': 197.215, 'highlights': ['Defining volume mappings and the need to define and use volumes properly The chapter emphasizes the importance of defining volume mappings in Docker Compose and the need to define volumes properly before using them, ensuring that data is stored outside the container by mapping a volume to a specific directory.', 'Availability of various subcommands for managing the application as a whole The chapter highlights the availability of various subcommands in Docker Compose for managing the application as a whole, including removing stopped containers, building images, listing services, and pulling newer versions of images.', 'Syntax and ordering of services in Docker Compose The chapter discusses the syntax and ordering of services in Docker Compose, allowing flexibility in ordering services from front to back or vice versa while defining properties such as volumes and adding line breaks for improved readability.']}], 'duration': 386.01, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1007381.jpg', 'highlights': ['Mongo version 4 image on Xenio, Ubuntu 16, preferred over Windows images due to smaller size', 'Port mappings defined for front end and API applications to map host ports to container ports', 'Environment variables configured for API project, including MongoDB connection string and db_url property', 'Importance of defining volume mappings in Docker Compose and using volumes properly', 'Availability of various subcommands in Docker Compose for managing the application as a whole', 'Discussion of syntax and ordering of services in Docker Compose for flexibility and improved readability']}, {'end': 1975.445, 'segs': [{'end': 1422.077, 'src': 'embed', 'start': 1394.132, 'weight': 0, 'content': [{'end': 1399.175, 'text': "So in this lesson I'm not going to use any of this, we're just going to run docker compose build.", 'start': 1394.132, 'duration': 5.043}, {'end': 1409.134, 'text': 'built our web and api services and, as you noticed, our build was super fast because pretty much everything came from the cache.', 'start': 1401.252, 'duration': 7.882}, {'end': 1412.615, 'text': "so let's run docker images.", 'start': 1409.134, 'duration': 3.481}, {'end': 1418.736, 'text': 'so i have five images on this machine, with the front end, with the web, with the api with the backend,', 'start': 1412.615, 'duration': 6.121}, {'end': 1422.077, 'text': 'and mongo mongo obviously came from docker hub.', 'start': 1418.736, 'duration': 3.341}], 'summary': 'Docker compose build resulted in fast build process with 5 images, including mongo from docker hub.', 'duration': 27.945, 'max_score': 1394.132, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1394132.jpg'}, {'end': 1488.312, 'src': 'embed', 'start': 1462.522, 'weight': 6, 'content': [{'end': 1468.887, 'text': 'so currently we are inside a directory called whitley, and that is why all these images are prefixed with whitley.', 'start': 1462.522, 'duration': 6.365}, {'end': 1470.128, 'text': 'i think this is a great convention.', 'start': 1468.887, 'duration': 1.241}, {'end': 1471.629, 'text': 'Now I got a question for you.', 'start': 1470.808, 'duration': 0.821}, {'end': 1476.956, 'text': 'If you look at the created column, you can see all these images were created an hour ago.', 'start': 1472.17, 'duration': 4.786}, {'end': 1482.163, 'text': "But didn't we just build the web and API images? Why do you think this happened? Here's the answer.", 'start': 1477.477, 'duration': 4.686}, {'end': 1488.312, 'text': 'Because I built these images frontend and backend an hour ago, when I was recording the first lesson in this section.', 'start': 1482.824, 'duration': 5.488}], 'summary': "Images in 'whitley' directory have 'whitley' prefix, created an hour ago during recording of first lesson.", 'duration': 25.79, 'max_score': 1462.522, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1462522.jpg'}, {'end': 1583.784, 'src': 'embed', 'start': 1504.42, 'weight': 1, 'content': [{'end': 1512.384, 'text': 'Now, if you want to force a full rebuild, we can say docker compose build dash dash no cache.', 'start': 1504.42, 'duration': 7.964}, {'end': 1517.226, 'text': "Alright, this is going to take a few seconds, so I'll be right back.", 'start': 1515.145, 'duration': 2.081}, {'end': 1524.685, 'text': "Alright, our images are built, so let's run docker images, there you go.", 'start': 1520.103, 'duration': 4.582}, {'end': 1528.966, 'text': 'Look at the first two images, api and web, were built less than a minute ago.', 'start': 1525.225, 'duration': 3.741}, {'end': 1533.768, 'text': "So that's all about building images, next we're going to talk about starting the application.", 'start': 1529.666, 'duration': 4.102}, {'end': 1543.907, 'text': 'you briefly saw how we can start an application with docker compose.', 'start': 1540.984, 'duration': 2.923}, {'end': 1546.571, 'text': 'We just type docker compose up.', 'start': 1544.388, 'duration': 2.183}, {'end': 1553.999, 'text': "Now, if the images are ready, docker compose will run them inside containers, otherwise it's going to build the images automatically.", 'start': 1547.432, 'duration': 6.567}, {'end': 1558.084, 'text': "Now, before executing this, let's look at the available options.", 'start': 1554.58, 'duration': 3.504}, {'end': 1561.467, 'text': 'So here we have a ton of options.', 'start': 1559.125, 'duration': 2.342}, {'end': 1564.169, 'text': 'a couple of them that are useful are build.', 'start': 1561.467, 'duration': 2.702}, {'end': 1573.656, 'text': "with this we can force a rebuild every time we want to start our application, so we don't have to explicitly run docker, compose, build and then up.", 'start': 1564.169, 'duration': 9.487}, {'end': 1577.359, 'text': 'We can combine the two using the build option.', 'start': 1574.317, 'duration': 3.042}, {'end': 1581.302, 'text': 'The other useful option is dash d for detached mode.', 'start': 1577.959, 'duration': 3.343}, {'end': 1583.784, 'text': 'So we will start these containers in the background.', 'start': 1581.742, 'duration': 2.042}], 'summary': "Using 'docker compose build' can rebuild images; 'docker compose up' starts application with various options available.", 'duration': 79.364, 'max_score': 1504.42, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1504420.jpg'}, {'end': 1684.35, 'src': 'embed', 'start': 1657.097, 'weight': 4, 'content': [{'end': 1660.699, 'text': 'This will stop and remove these containers, but the images are still there.', 'start': 1657.097, 'duration': 3.602}, {'end': 1664.84, 'text': 'So next time we want to start the application, our application will start pretty quickly.', 'start': 1661.219, 'duration': 3.621}, {'end': 1673.461, 'text': "Let's talk about networking in docker.", 'start': 1671.94, 'duration': 1.521}, {'end': 1681.047, 'text': 'When we run our application with docker compose, docker compose will automatically create a network and add our containers on that network.', 'start': 1673.962, 'duration': 7.085}, {'end': 1682.949, 'text': 'So these containers can talk to each other.', 'start': 1681.388, 'duration': 1.561}, {'end': 1684.35, 'text': "Let's see this in action.", 'start': 1683.55, 'duration': 0.8}], 'summary': 'Using docker compose creates network for quick application start and inter-container communication.', 'duration': 27.253, 'max_score': 1657.097, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1657097.jpg'}, {'end': 1942.214, 'src': 'embed', 'start': 1910.259, 'weight': 5, 'content': [{'end': 1913.521, 'text': 'And that is why we have this port mapping over here.', 'start': 1910.259, 'duration': 3.262}, {'end': 1918.185, 'text': 'So this port on the host is mapped to this port on the container.', 'start': 1914.302, 'duration': 3.883}, {'end': 1929.449, 'text': 'So if you open up MongoDB compass, which is a popular MongoDB client, we can establish a connection to local host port 27017.', 'start': 1919.145, 'duration': 10.304}, {'end': 1931.19, 'text': 'Because this port is mapped to our container.', 'start': 1929.449, 'duration': 1.741}, {'end': 1932.791, 'text': "Let's verify this real quick.", 'start': 1931.61, 'duration': 1.181}, {'end': 1934.751, 'text': 'So connect, great.', 'start': 1933.211, 'duration': 1.54}, {'end': 1942.214, 'text': "So here we can see all our databases, here's our fitly database, and in this database we have a collection called movies with four documents.", 'start': 1935.252, 'duration': 6.962}], 'summary': "Port mapping allows connection to mongodb on local host port 27017, with a 'fitly' database containing a 'movies' collection and four documents.", 'duration': 31.955, 'max_score': 1910.259, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1910259.jpg'}], 'start': 1394.132, 'title': 'Docker compose and networking in docker', 'summary': 'Covers fast image building with docker compose resulting in five images, and discusses reasons behind creation time. it also includes building docker images, running containers, and networking with docker compose, covering commands, options, network creation, container communication, and accessing containers through port mappings.', 'chapters': [{'end': 1482.163, 'start': 1394.132, 'title': 'Docker compose image building', 'summary': 'Explains the fast image building process using docker compose, resulting in five images created, with the front end, web, api, backend, and mongo, all prefixed with the application name, and discusses the reasons behind the creation time of the images.', 'duration': 88.031, 'highlights': ['The chapter explains the fast image building process using Docker Compose, resulting in five images created, with the front end, web, API, backend, and mongo, all prefixed with the application name.', 'The created column shows all the images were created an hour ago, despite building only the web and API images, prompting a question on the reason behind this.']}, {'end': 1975.445, 'start': 1482.824, 'title': 'Building, running, and networking with docker', 'summary': 'Covers building docker images, running containers, and networking with docker compose, including commands and options, network creation, container communication, and accessing containers through port mappings.', 'duration': 492.621, 'highlights': ["We can force a full rebuild of Docker images using 'docker compose build --no-cache', which takes a few seconds. Force a full rebuild of Docker images using 'docker compose build --no-cache', taking a few seconds.", "Docker compose allows starting applications with 'docker compose up', automatically running images inside containers if ready, otherwise building images. Docker compose allows starting applications with 'docker compose up', automatically running images inside containers if ready, otherwise building images.", "The 'build' option in Docker compose allows forcing a rebuild every time the application starts, combining 'docker compose build' and 'up'. The 'build' option in Docker compose allows forcing a rebuild every time the application starts, combining 'docker compose build' and 'up'.", "Running 'docker compose ps' displays all relevant containers for the application, while 'docker ps' shows all running containers across applications. Running 'docker compose ps' displays all relevant containers for the application, while 'docker ps' shows all running containers across applications.", 'Docker compose can automatically create a network and add containers to it, enabling communication between containers using their names. Docker compose can automatically create a network and add containers to it, enabling communication between containers using their names.', 'Containers in the same network can communicate with each other using the embedded DNS server and DNS resolver to find the IP address of the target container. Containers in the same network can communicate with each other using the embedded DNS server and DNS resolver to find the IP address of the target container.', 'Accessing containers through port mappings allows communication between containers and external access, as demonstrated with a MongoDB client establishing a connection. Accessing containers through port mappings allows communication between containers and external access, as demonstrated with a MongoDB client establishing a connection.']}], 'duration': 581.313, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HG6yIjZapSA/pics/HG6yIjZapSA1394132.jpg', 'highlights': ['The chapter explains the fast image building process using Docker Compose, resulting in five images created, with the front end, web, API, backend, and mongo, all prefixed with the application name.', "We can force a full rebuild of Docker images using 'docker compose build --no-cache', which takes a few seconds.", "Docker compose allows starting applications with 'docker compose up', automatically running images inside containers if ready, otherwise building images.", "The 'build' option in Docker compose allows forcing a rebuild every time the application starts, combining 'docker compose build' and 'up'.", 'Docker compose can automatically create a network and add containers to it, enabling communication between containers using their names.', 'Accessing containers through port mappings allows communication between containers and external access, as demonstrated with a MongoDB client establishing a connection.', 'The created column shows all the images were created an hour ago, despite building only the web and API images, prompting a question on the reason behind this.']}], 'highlights': ['Docker Compose simplifies setting up multi-container applications, saving time and effort.', 'Docker Compose automatically populates the database with movies, showcasing real-world scenarios.', 'YAML is easier to read and understand compared to JSON, with less clutter and hierarchical representation.', 'Setting the version to 3.8 for the latest features in Docker Compose.', 'Port mappings defined for front end and API applications to map host ports to container ports.', 'Environment variables configured for API project, including MongoDB connection string and db_url property.', "Docker Compose allows starting applications with 'docker compose up', automatically running images inside containers if ready, otherwise building images.", 'Docker Compose can automatically create a network and add containers to it, enabling communication between containers using their names.']}