What is Docker Compose?
45sQuickly explains the core concept of Docker Compose in under a minute, perfect for beginners.
▶ Play ClipDocker Compose is a tool for managing multiple containers together using a single YAML configuration file, saving time and reducing errors. It allows you to start or stop all containers with one command, making it ideal for multi-service environments like web apps with databases and caches.
Docker Compose manages multiple containers together instead of running many commands one by one.
Saves time, avoids mistakes, and is perfect for environments with many services like web applications, databases, and caches.
YAML (YAML Ain't Markup Language) is a simple text format for configuration files, using key-value pairs and spaces for indentation.
Use official method: sudo apt install docker-compose-plugin. Avoid old curl methods for safety.
Use a text editor like nano or vi to create a file named docker-compose.yml with version, services, images, environment variables, and ports.
Use 'docker compose up -d' to start containers in detached mode. Use '-f' for custom file names.
Example YAML for LAMP (Linux, Apache, MySQL, PHP) stack with MySQL, Tomcat, and PHP services linked together.
Example YAML for Jenkins, Tomcat dev, and Tomcat prod services with port mappings and links.
Example YAML for Selenium Grid with hub and Firefox nodes on ports 4444, 5901, 5902.
Docker Compose simplifies multi-container management using YAML files, enabling quick setup and teardown of complex environments with a single command.
"Title accurately describes a beginner tutorial with step-by-step YAML and demo, though '2026' is misleading."
What is Docker Compose?
A tool to manage multiple containers together using a single YAML file.
What does YAML stand for?
YAML Ain't Markup Language.
1:02
What is the correct command to install Docker Compose plugin?
sudo apt install docker-compose-plugin
5:41
How do you verify Docker Compose installation?
Run 'docker compose version'.
6:05
What is the default file name for Docker Compose?
docker-compose.yml
8:53
What command starts containers in detached mode?
docker compose up -d
12:11
What does LAMP stand for?
Linux, Apache, MySQL, PHP.
18:45
What is the purpose of the 'links' key in Docker Compose?
To link services together, e.g., linking Tomcat to MySQL.
16:06
How do you remove all containers created by Docker Compose?
Run 'docker compose down'.
27:53
What port does Jenkins typically run on?
8080, but in the example it is mapped to 7070.
21:04
Warning against old curl method
Strong emphasis on security by avoiding outdated installation methods.
5:03First successful container run
Moment when the YAML file is executed and containers start running.
12:11Jenkins QA Prod setup
Demonstrates a real-world multi-service environment with Jenkins and Tomcat.
20:36[00:00] So, what is Docker Compose?
[00:04] Docker Compose is a tool to manage multiple containers together instead of
[00:09] running many
[00:14] commands one by one.
[00:19] So, you can create one file called Docker Compose.ml with the single
[00:24] command you can
[00:28] start or stop all the containers and you can manage all the
[00:33] containers at a time.
[00:38] So, why it is useful means one key is a time save
[00:43] open the envelope and we can avoid some
[00:48] mistakes also, perfect for creating environments with many services like web applications
[00:52] and
[00:57] database and the caches.
[01:02] So, as I told you, AML stands for at another markup language,
[01:07] it is a simple text format
[01:12] for writing configuration files and the application law apply it want to
[01:16] type of configurations
[01:21] which you are on call.
[01:26] So, when you run the file automatically based on the changes, the
[01:31] containers will get managed.
[01:36] So, data is written as a key value pairs and uses spaces
[01:41] for indentations, node apps, not
[01:45] it is not a scripting language, just a way to describe the
[01:50] data structure.
[01:55] So, example Mhu McOoo.
[02:00] AML file Lopla, Evatengam
[02:05] indentation is nothing but the space, so just I said hereanos just
[02:09] I said this key and the
[02:14] right side is equality, left side is key and right side is
[02:19] value like this.
[02:24] So, how to valid it, so how to valid it, let me
[02:29] create instance quickly here for this purpose.
[02:33] First I am going to say here Docker, iPhone Compose, right, Ubuntu
[02:38] mission name selecting
[02:43] here, keeper, the network settings. So, for the practice and testing purpose,
[02:48] just
[02:53] I am going to add one more security group rule and I
[02:57] am setting it to all traffic and
[03:02] the source type anywhere. So, no need to open all the ports
[03:07] one by one, okay, for every
[03:12] application, that is the reason, right, now click on launch instance. So,
[03:17] once instance
[03:22] launching in the other one or login or other, so just click
[03:26] on view all instances, now
[03:31] let us select your instance, click on connect and copy the command
[03:36] and how to install this
[03:41] Docker. So, you already know, the two I think, so I told
[03:46] you, right. So, to install Docker,
[03:50] we give the curl command, okay, let me open the command prompt
[03:55] now. So, go to the location
[04:00] where keeper is available and just paste the SSH command here, now
[04:05] type s, now you can
[04:10] see we have connected to the Ubuntu mission. So, just the first
[04:14] command I am going to pass
[04:19] your sudo apt, if and get update, to update the packages, previous
[04:24] concept Sunday practice
[04:29] and in videos published on my group law, previous topics and I
[04:34] have a doubt, so I have so these
[04:38] are lalitha karu. Now, let us install the Docker first, so the
[04:43] curl command I am giving here,
[04:48] okay, okay, so how to run this sudo space s, s, s,
[04:53] s, get type and docker dot s,
[04:58] so after installing the Docker, we need to install the Docker compose,
[05:03] so it is the Docker
[05:07] compose and it is a plugin and matter, right. So, warning, what
[05:12] is the warning here, do not
[05:17] use old GitHub, come to the end and day, GitHub link, Docker
[05:22] compose new install, that
[05:27] is the old method. So, always do not give any curl commands,
[05:31] always use official method
[05:36] for the safety and security. So, just pass the command sudo apt
[05:41] update, we have already
[05:46] done this one and after that, you need to give this command
[05:51] to install Docker compose sudo
[05:55] apt install Docker iPhone compose iPhone plugin. Now, the plugin was installed,
[06:00] so how to verify
[06:05] it, just pass the command, do not give iPhone here, Docker compose
[06:10] version. So, it will show
[06:15] you the version of the Docker compose. So, there is a space
[06:19] between Docker and compose
[06:24] in the new command, okay. So, if you see a version number,
[06:29] Docker compose is installed
[06:34] correctly, you should know if you get any permission errors, I already
[06:39] done this slide,
[06:44] so just you need to remember these key points, Docker compose uses
[06:48] AML files. So, this compose
[06:53] plugin will use AML files to define and run multiple multi container
[06:58] Docker applications.
[07:03] AML files are all about indentation and key value. If the everything
[07:08] of our component based
[07:12] on the indentation and the left side you can read as key
[07:17] and right side, there will be
[07:22] a value. So, be careful with these spaces, spaces are nothing but
[07:27] the indentations, right.
[07:32] Validate your AML files before using in real projects, install Docker compose
[07:36] apt not by
[07:41] downloading scripts from the internet. Okay, now let's move to the practical
[07:46] part. So, we
[07:51] can manage our containers together with the help of this Docker compose,
[07:56] it's a AML is
[08:00] a special configuration file with the Docker compose, you can start all
[08:05] containers with
[08:10] just one command. So, as I told you stands were at another
[08:15] markup language, it uses key
[08:20] value based strictly indentation spaces not tabs. AML files are not scripts,
[08:25] they describe
[08:29] data and relationships not actions. What is the tip here, indentations are
[08:34] error indentation
[08:39] errors are the most common issue only spaces never tabs. Creating and
[08:44] understanding a
[08:49] Docker compose file. So, open a open or create the AML file,
[08:53] just you need to open the terminal
[08:58] and use you can text it as you can use like Nimn
[09:03] nano or vi, any text you can use. So,
[09:08] in this case we have used a text editor called bin and
[09:13] this is the, so just I am going to
[09:17] create a file here, file m is Docker f and compose dot
[09:22] AML. So, go to the insert mode and
[09:27] copy this syntax. So, in order to understand this first we have
[09:32] given the version, it will
[09:37] tell you the format version for the compose and services next image
[09:41] among services itself
[09:46] under the services we have DB services means all containers are listed
[09:51] under this key.
[09:56] So, like you can manipulate my DB and itself. So, my DB
[10:01] and my site service container names
[10:06] these are and image after that what will be their image, image
[10:10] name. The image name
[10:15] here we are using is MySQL. So, database it is related to
[10:20] and environment, iPhone E. So,
[10:25] using this iPhone E option we can pass user names, passwords into
[10:30] the application from
[10:34] the container itself. So, we can give and assign some ports to
[10:39] the application. So, here we
[10:44] are assigning 50 port. So, let us say I am going to
[10:49] copy the center code which I have
[10:54] and just I am going to the VM editor or syntax or
[10:58] whatever. So, just to go to escape I am
[11:03] going to put this one. So, just let me use nano instead
[11:08] of this one Docker compose,
[11:13] Docker iPhone compose dot AML. So, go to let us paste this
[11:18] or else let us use VIRLs.
[11:22] We are using the Docker iPhone compose dot AML and again go
[11:27] to insert mode. So, we put
[11:32] search for that. So, I could be coordinate this one and just
[11:37] click on go. So, valid AML
[11:42] it will it will tell you as it is a valid AML.
[11:47] Well, in case I make a valid AML and
[11:51] it is syntax error same layer in two. So, just in the
[11:56] terminal again go to the terminal
[12:01] now press escape colon WQ7 bit. So, now let us run the
[12:06] Docker this AML code. So, what
[12:11] is how to run this? So, just so just in order to
[12:15] start the container just you need to say
[12:20] Docker compose up iPhone D. So, just I am going to pass
[12:25] the command. So, you put current
[12:30] location either on the current location by default, Docker iPhone compose dot
[12:35] AML particularly
[12:39] on the internet, this is called on the matter file name other
[12:44] than the only check just Docker
[12:49] well, in case file name here you may merge the unit to
[12:54] you go for the iPhone F option.
[12:59] So, obviously, it is asking for the permissions which were denied. So,
[13:03] just I am going to
[13:08] say pseudo in front of this. So, you can see that images
[13:13] and pull out right. So, the environment
[13:18] is getting created now. So, let us go with the another example.
[13:23] So, example 2 is lamp
[13:28] stack MySQL, Tomcat, Apache and PHP. So, even even in the whole
[13:32] the create just now put
[13:37] at how commands passes. So, if we want to go to mono
[13:42] of file or pity just we are going
[13:47] to run the Docker compose command right. So, we are creating the
[13:52] one AML file and we are
[13:56] running the Docker compose up command right. So, then give file name
[14:01] let us go with the
[14:06] same file. So, first of all in the mono creates in a
[14:11] file either on the containers we remove
[14:16] channel and the command will be Docker remove old containers the command
[14:20] is Docker rm space
[14:25] iPhone F and you need to pass this command ok. So, it
[14:30] will remove all the old containers
[14:35] ok. So, I am going in the example 2, I am going
[14:40] to remove the old file instructions if it
[14:44] is not on a MySQL along with that one web application we
[14:49] are going to install that is
[14:54] nothing, but the Tomcat and we are going to install on programacle
[14:59] part that is PHP ok.
[15:04] So, this is the syntax SQL API install in Docker compose ok.
[15:09] Now, lamp architecture lamp stack
[15:13] MySQL services under the services you can see we are going to
[15:18] pull the image called MySQL
[15:23] and a SQL upload monomanias now we are setting up the password
[15:28] by giving the environment variables
[15:33] setting up environment variables and we are going to pull up apache
[15:37] web server also and
[15:42] the image name here I am going to use as tommy. So,
[15:47] it means the Tomcat image will get pulled
[15:52] from the Docker hub and I am going to give the port
[15:57] as 6060 for this Tomcat image. So,
[16:01] links I am giving as I am going to link this my
[16:06] DB links I am giving MySQL name we are
[16:11] going to change it to my DB and here we are going
[16:16] to link it to my database right. So,
[16:21] the Tomcat image on a database so link just now and we
[16:25] are pulling the PHP image also this
[16:30] is the entire syntax ok. So, I just I am going to
[16:35] copy this syntax and I am going to paste
[16:40] it here. So, now escape colon wq7 now how to run the
[16:45] command. So, just you need to say
[16:50] Docker compose up space if and the if and e means detached
[16:54] mode mono host machine no
[16:59] no one term but the command will get executed and the containers
[17:04] will run at the background
[17:09] right. So, just let me bring up this. So, you can see
[17:14] now it is pulling PHP apache this is
[17:18] all images it is getting pulled from the Docker hub. So, it
[17:23] is very easy process. So,
[17:28] one or two times I am going to EAML file write over
[17:33] just a easily you can do this one
[17:38] ok. But in case EAML file in case EAML file, EAML code
[17:42] write them I will you know class
[17:47] I am going to make a note and it says just you
[17:52] know the employee EAML code explanation
[17:57] will run to me. So, just I create an EAML code but
[18:02] economic example so how I am going
[18:06] to I image the container sim on even the manage as known
[18:11] as other just on that. So, lamps
[18:16] the EAML architecture we have created lamp and they in the last
[18:21] class also I told you
[18:26] what is the meaning of lamp what is the meaning of lamp
[18:31] ok. Enter web application key
[18:35] kavasana environment anta kudha we can create using lamp architecture. So, lamp
[18:40] full form
[18:45] into lalthikar we have an idea on the meko. L stands for
[18:50] what A stands for what M stands
[18:55] very good Linux Apache very good my SQL and PHP that is
[18:59] what ok. So, yes. So, after this
[19:04] let us remove the old containers and let us go to the
[19:09] other practical part. So, now I
[19:14] am going to stop either me call it access code just go
[19:19] to you can access other people
[19:23] in the entire let us go to you can copy the public
[19:28] IP of your machine and you can give
[19:33] 60 60 port. So, let us go to the AWS now and
[19:38] go back to the instances copy the public IP
[19:43] of it and just I am going to paste it here and
[19:47] call on 60 60 you can check whether your
[19:52] application is working or not. See while in case me re-page go
[19:57] to the code of the ludha
[20:02] runtime Tomcat was successfully installed the application ok in your system. So,
[20:07] let me
[20:12] remove all the containers let me stop and remove all the containers
[20:16] ok all the three
[20:21] containers stopped you can see right. So, now next thing what we
[20:26] are going to do means
[20:31] here lamb stack completed now we can create Jenkins QA prod using
[20:36] Tomcat right. So, we
[20:40] can install. So, what is the version here we are giving the
[20:45] version as three and what type
[20:50] of services dev instance we are creating and we are going to
[20:55] pull the image call Jenkins
[21:00] and we are setting it up to the port called 70 70
[21:04] by default make a Jenkins task a port
[21:09] may come to me 80 80 port long to me. So, we
[21:14] are going to pull one more image called
[21:19] Tommy Tommy is nothing, but the Tomcat Tomcat server. So, ok. So,
[21:24] in a port such as number
[21:28] of 18 8 double 9 ok by default it will also pick
[21:33] 80 80 and after that we are going to
[21:38] link this dev server to Jenkins right and after that prod instance
[21:43] also we are creating
[21:48] and after that we are pulling inside this instance one more image
[21:53] again Tommy and here
[21:57] I am changing this port to 1990 and we are linking it
[22:02] to dev server Jenkins ok.
[22:07] So, let me copy this entire code and its syntax first. So,
[22:12] copy the command and go
[22:17] to the VA editor, go to the AML file and go to
[22:21] inset mode, press escape first, delete
[22:26] the previous AML syntax and just I am going to paste the
[22:31] new syntax here. So, now let
[22:36] me go to inset mode, press escape now colon wq save and
[22:41] click ok. So, just type Ls, you
[22:45] can see our AML file is there here. So, just how to
[22:50] run the file. So, just give the command
[22:55] docker space compose space up I find D. So, you put in
[23:00] your only one of the main Jenkins
[23:05] there. So, how much time it was taken for me. So, almost
[23:09] one hour particularly, so now
[23:14] we are going to do that job for us. So, automatically. So,
[23:19] it can manual effort, there
[23:24] is no manual effort at all right. So, just press enter now.
[23:29] So, it is going to pull the
[23:34] new server. So, simply you can access each and everything. So, just
[23:38] me room a instance
[23:43] of public IP is contour and whatever the port numbers you have
[23:48] given for those applications
[23:53] you can directly access them into your browser. So, just go to
[23:58] the console, just copy the public
[24:02] IP of the instance now. So, I will work out now a
[24:07] lecture now. So, I am on Jenkins port
[24:12] number even the school number, 70, 70 and each other. So, just
[24:17] open the chrome browser
[24:22] just paste the public IP and I am giving colon 70, 70.
[24:26] Now, press enter see the Jenkins
[24:31] is going to ask you for the password now. So, Jenkins work
[24:36] out from there. Next time
[24:41] the chammono or Tomcat in KI. So, now, let us copy the
[24:46] public IP of our instance. So,
[24:50] you can see check all the containers are running or not. Just
[24:55] give the comment here
[25:00] Docker container. Alas, it will list out all the containers. See two
[25:05] Tomcat server, Tomcat
[25:10] of our publications are running right and one Jenkins was installed in
[25:15] the dev instance
[25:19] right. So, now, let us try to access it and I am
[25:24] going to chammono. We have assigned it
[25:29] 80 at 90, 70, 70, 80 default together, 70, 70 chammono. Now,
[25:34] call on 70, 70. Okay, Jenkins
[25:39] has a successful run out may no problem at all and what
[25:43] about the Tomcat, double 8,
[25:48] double 9 and 90. Okay. Now, let us go to console and
[25:53] go to check the proper go panjas
[25:58] let us pass double 9, double 9 Tomcat application should get.
[26:03] Oh, he taught me. Okay. 80, 80 portal on the bar. The
[26:07] 88 double n again.
[26:12] Go to insert mode and what is the example for here, the
[26:17] syntax.
[26:22] Copy this syntax, go back to terminal, just paste it. Now, press
[26:27] escape, WQ save and
[26:31] click it. Now, let us run this containers. So, how to run
[26:36] the container? Just you need
[26:41] to say Docker compose space up, I find D. Now, it is
[26:46] pulling all those images and we can
[26:51] access it giving the, what, double 4, double 4, 5 9 0
[26:56] 1 for V and C and 5 9 0 2, Firefox
[27:00] image was pulled from container started. So, just use the command Docker
[27:05] containers
[27:10] LS to see all the containers they are working fine or not.
[27:15] So, now, let us copy the public
[27:20] IP and test all our applications are working properly or not. So,
[27:24] what is the first port?
[27:29] Double 4, double 4. So, just give here double 4, double 4,
[27:34] the center. You can see Selenium
[27:39] grid interface successfully and next, what is the next port? On spatical
[27:44] port, type in
[27:48] the router, just remove all the containers. To remove all the containers,
[27:53] just pass this
[27:58] command. So, network, I will check, check, check, check, check, check, check.
[28:03] So tomorrow
[28:08] class I will tell you, I will go time to troubleshoot it.
[28:12] So, all the containers stopped
[28:17] and you can stop your instance also. So, there are doubts on
[28:22] the aragandic glass law,
[28:27] later on, I will add this session. No, it's not flat, it's
[28:32] just him. Please do practice.
⚡ Saved you time reading this? Transcribe any YouTube video for free — no signup needed.