---
title: 'Docker Compose Tutorial for Beginners 2026 | Step-by-Step YAML, Commands & Real Demo'
source: 'https://youtube.com/watch?v=Xwu1Pbmh6t0'
video_id: 'Xwu1Pbmh6t0'
date: 2026-06-13
duration_sec: 1698
---

# Docker Compose Tutorial for Beginners 2026 | Step-by-Step YAML, Commands & Real Demo

> Source: [Docker Compose Tutorial for Beginners 2026 | Step-by-Step YAML, Commands & Real Demo](https://youtube.com/watch?v=Xwu1Pbmh6t0)

## Summary

Docker 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.

### Key Points

- **What is Docker Compose?** [0:00] — Docker Compose manages multiple containers together instead of running many commands one by one.
- **Why Docker Compose is useful** [0:38] — Saves time, avoids mistakes, and is perfect for environments with many services like web applications, databases, and caches.
- **YAML file basics** [1:02] — YAML (YAML Ain't Markup Language) is a simple text format for configuration files, using key-value pairs and spaces for indentation.
- **Installing Docker Compose** [5:03] — Use official method: sudo apt install docker-compose-plugin. Avoid old curl methods for safety.
- **Creating a Docker Compose file** [8:53] — Use a text editor like nano or vi to create a file named docker-compose.yml with version, services, images, environment variables, and ports.
- **Running containers with Docker Compose** [12:11] — Use 'docker compose up -d' to start containers in detached mode. Use '-f' for custom file names.
- **LAMP stack example** [15:04] — Example YAML for LAMP (Linux, Apache, MySQL, PHP) stack with MySQL, Tomcat, and PHP services linked together.
- **Jenkins QA Prod example** [20:36] — Example YAML for Jenkins, Tomcat dev, and Tomcat prod services with port mappings and links.
- **Selenium Grid example** [26:22] — Example YAML for Selenium Grid with hub and Firefox nodes on ports 4444, 5901, 5902.

### Conclusion

Docker Compose simplifies multi-container management using YAML files, enabling quick setup and teardown of complex environments with a single command.

## Transcript

So, what is Docker Compose?
Docker Compose is a tool to manage multiple containers together instead of
running many
commands one by one.
So, you can create one file called Docker Compose.ml with the single
command you can
start or stop all the containers and you can manage all the
containers at a time.
So, why it is useful means one key is a time save
open the envelope and we can avoid some
mistakes also, perfect for creating environments with many services like web applications
and
database and the caches.
So, as I told you, AML stands for at another markup language,
it is a simple text format
for writing configuration files and the application law apply it want to
type of configurations
which you are on call.
So, when you run the file automatically based on the changes, the
containers will get managed.
So, data is written as a key value pairs and uses spaces
for indentations, node apps, not
it is not a scripting language, just a way to describe the
data structure.
So, example Mhu McOoo.
AML file Lopla, Evatengam
indentation is nothing but the space, so just I said hereanos just
I said this key and the
right side is equality, left side is key and right side is
value like this.
So, how to valid it, so how to valid it, let me
create instance quickly here for this purpose.
First I am going to say here Docker, iPhone Compose, right, Ubuntu
mission name selecting
here, keeper, the network settings. So, for the practice and testing purpose,
just
I am going to add one more security group rule and I
am setting it to all traffic and
the source type anywhere. So, no need to open all the ports
one by one, okay, for every
application, that is the reason, right, now click on launch instance. So,
once instance
launching in the other one or login or other, so just click
on view all instances, now
let us select your instance, click on connect and copy the command
and how to install this
Docker. So, you already know, the two I think, so I told
you, right. So, to install Docker,
we give the curl command, okay, let me open the command prompt
now. So, go to the location
where keeper is available and just paste the SSH command here, now
type s, now you can
see we have connected to the Ubuntu mission. So, just the first
command I am going to pass
your sudo apt, if and get update, to update the packages, previous
concept Sunday practice
and in videos published on my group law, previous topics and I
have a doubt, so I have so these
are lalitha karu. Now, let us install the Docker first, so the
curl command I am giving here,
okay, okay, so how to run this sudo space s, s, s,
s, get type and docker dot s,
so after installing the Docker, we need to install the Docker compose,
so it is the Docker
compose and it is a plugin and matter, right. So, warning, what
is the warning here, do not
use old GitHub, come to the end and day, GitHub link, Docker
compose new install, that
is the old method. So, always do not give any curl commands,
always use official method
for the safety and security. So, just pass the command sudo apt
update, we have already
done this one and after that, you need to give this command
to install Docker compose sudo
apt install Docker iPhone compose iPhone plugin. Now, the plugin was installed,
so how to verify
it, just pass the command, do not give iPhone here, Docker compose
version. So, it will show
you the version of the Docker compose. So, there is a space
between Docker and compose
in the new command, okay. So, if you see a version number,
Docker compose is installed
correctly, you should know if you get any permission errors, I already
done this slide,
so just you need to remember these key points, Docker compose uses
AML files. So, this compose
plugin will use AML files to define and run multiple multi container
Docker applications.
AML files are all about indentation and key value. If the everything
of our component based
on the indentation and the left side you can read as key
and right side, there will be
a value. So, be careful with these spaces, spaces are nothing but
the indentations, right.
Validate your AML files before using in real projects, install Docker compose
apt not by
downloading scripts from the internet. Okay, now let's move to the practical
part. So, we
can manage our containers together with the help of this Docker compose,
it's a AML is
a special configuration file with the Docker compose, you can start all
containers with
just one command. So, as I told you stands were at another
markup language, it uses key
value based strictly indentation spaces not tabs. AML files are not scripts,
they describe
data and relationships not actions. What is the tip here, indentations are
error indentation
errors are the most common issue only spaces never tabs. Creating and
understanding a
Docker compose file. So, open a open or create the AML file,
just you need to open the terminal
and use you can text it as you can use like Nimn
nano or vi, any text you can use. So,
in this case we have used a text editor called bin and
this is the, so just I am going to
create a file here, file m is Docker f and compose dot
AML. So, go to the insert mode and
copy this syntax. So, in order to understand this first we have
given the version, it will
tell you the format version for the compose and services next image
among services itself
under the services we have DB services means all containers are listed
under this key.
So, like you can manipulate my DB and itself. So, my DB
and my site service container names
these are and image after that what will be their image, image
name. The image name
here we are using is MySQL. So, database it is related to
and environment, iPhone E. So,
using this iPhone E option we can pass user names, passwords into
the application from
the container itself. So, we can give and assign some ports to
the application. So, here we
are assigning 50 port. So, let us say I am going to
copy the center code which I have
and just I am going to the VM editor or syntax or
whatever. So, just to go to escape I am
going to put this one. So, just let me use nano instead
of this one Docker compose,
Docker iPhone compose dot AML. So, go to let us paste this
or else let us use VIRLs.
We are using the Docker iPhone compose dot AML and again go
to insert mode. So, we put
search for that. So, I could be coordinate this one and just
click on go. So, valid AML
it will it will tell you as it is a valid AML.
Well, in case I make a valid AML and
it is syntax error same layer in two. So, just in the
terminal again go to the terminal
now press escape colon WQ7 bit. So, now let us run the
Docker this AML code. So, what
is how to run this? So, just so just in order to
start the container just you need to say
Docker compose up iPhone D. So, just I am going to pass
the command. So, you put current
location either on the current location by default, Docker iPhone compose dot
AML particularly
on the internet, this is called on the matter file name other
than the only check just Docker
well, in case file name here you may merge the unit to
you go for the iPhone F option.
So, obviously, it is asking for the permissions which were denied. So,
just I am going to
say pseudo in front of this. So, you can see that images
and pull out right. So, the environment
is getting created now. So, let us go with the another example.
So, example 2 is lamp
stack MySQL, Tomcat, Apache and PHP. So, even even in the whole
the create just now put
at how commands passes. So, if we want to go to mono
of file or pity just we are going
to run the Docker compose command right. So, we are creating the
one AML file and we are
running the Docker compose up command right. So, then give file name
let us go with the
same file. So, first of all in the mono creates in a
file either on the containers we remove
channel and the command will be Docker remove old containers the command
is Docker rm space
iPhone F and you need to pass this command ok. So, it
will remove all the old containers
ok. So, I am going in the example 2, I am going
to remove the old file instructions if it
is not on a MySQL along with that one web application we
are going to install that is
nothing, but the Tomcat and we are going to install on programacle
part that is PHP ok.
So, this is the syntax SQL API install in Docker compose ok.
Now, lamp architecture lamp stack
MySQL services under the services you can see we are going to
pull the image called MySQL
and a SQL upload monomanias now we are setting up the password
by giving the environment variables
setting up environment variables and we are going to pull up apache
web server also and
the image name here I am going to use as tommy. So,
it means the Tomcat image will get pulled
from the Docker hub and I am going to give the port
as 6060 for this Tomcat image. So,
links I am giving as I am going to link this my
DB links I am giving MySQL name we are
going to change it to my DB and here we are going
to link it to my database right. So,
the Tomcat image on a database so link just now and we
are pulling the PHP image also this
is the entire syntax ok. So, I just I am going to
copy this syntax and I am going to paste
it here. So, now escape colon wq7 now how to run the
command. So, just you need to say
Docker compose up space if and the if and e means detached
mode mono host machine no
no one term but the command will get executed and the containers
will run at the background
right. So, just let me bring up this. So, you can see
now it is pulling PHP apache this is
all images it is getting pulled from the Docker hub. So, it
is very easy process. So,
one or two times I am going to EAML file write over
just a easily you can do this one
ok. But in case EAML file in case EAML file, EAML code
write them I will you know class
I am going to make a note and it says just you
know the employee EAML code explanation
will run to me. So, just I create an EAML code but
economic example so how I am going
to I image the container sim on even the manage as known
as other just on that. So, lamps
the EAML architecture we have created lamp and they in the last
class also I told you
what is the meaning of lamp what is the meaning of lamp
ok. Enter web application key
kavasana environment anta kudha we can create using lamp architecture. So, lamp
full form
into lalthikar we have an idea on the meko. L stands for
what A stands for what M stands
very good Linux Apache very good my SQL and PHP that is
what ok. So, yes. So, after this
let us remove the old containers and let us go to the
other practical part. So, now I
am going to stop either me call it access code just go
to you can access other people
in the entire let us go to you can copy the public
IP of your machine and you can give
60 60 port. So, let us go to the AWS now and
go back to the instances copy the public IP
of it and just I am going to paste it here and
call on 60 60 you can check whether your
application is working or not. See while in case me re-page go
to the code of the ludha
runtime Tomcat was successfully installed the application ok in your system. So,
let me
remove all the containers let me stop and remove all the containers
ok all the three
containers stopped you can see right. So, now next thing what we
are going to do means
here lamb stack completed now we can create Jenkins QA prod using
Tomcat right. So, we
can install. So, what is the version here we are giving the
version as three and what type
of services dev instance we are creating and we are going to
pull the image call Jenkins
and we are setting it up to the port called 70 70
by default make a Jenkins task a port
may come to me 80 80 port long to me. So, we
are going to pull one more image called
Tommy Tommy is nothing, but the Tomcat Tomcat server. So, ok. So,
in a port such as number
of 18 8 double 9 ok by default it will also pick
80 80 and after that we are going to
link this dev server to Jenkins right and after that prod instance
also we are creating
and after that we are pulling inside this instance one more image
again Tommy and here
I am changing this port to 1990 and we are linking it
to dev server Jenkins ok.
So, let me copy this entire code and its syntax first. So,
copy the command and go
to the VA editor, go to the AML file and go to
inset mode, press escape first, delete
the previous AML syntax and just I am going to paste the
new syntax here. So, now let
me go to inset mode, press escape now colon wq save and
click ok. So, just type Ls, you
can see our AML file is there here. So, just how to
run the file. So, just give the command
docker space compose space up I find D. So, you put in
your only one of the main Jenkins
there. So, how much time it was taken for me. So, almost
one hour particularly, so now
we are going to do that job for us. So, automatically. So,
it can manual effort, there
is no manual effort at all right. So, just press enter now.
So, it is going to pull the
new server. So, simply you can access each and everything. So, just
me room a instance
of public IP is contour and whatever the port numbers you have
given for those applications
you can directly access them into your browser. So, just go to
the console, just copy the public
IP of the instance now. So, I will work out now a
lecture now. So, I am on Jenkins port
number even the school number, 70, 70 and each other. So, just
open the chrome browser
just paste the public IP and I am giving colon 70, 70.
Now, press enter see the Jenkins
is going to ask you for the password now. So, Jenkins work
out from there. Next time
the chammono or Tomcat in KI. So, now, let us copy the
public IP of our instance. So,
you can see check all the containers are running or not. Just
give the comment here
Docker container. Alas, it will list out all the containers. See two
Tomcat server, Tomcat
of our publications are running right and one Jenkins was installed in
the dev instance
right. So, now, let us try to access it and I am
going to chammono. We have assigned it
80 at 90, 70, 70, 80 default together, 70, 70 chammono. Now,
call on 70, 70. Okay, Jenkins
has a successful run out may no problem at all and what
about the Tomcat, double 8,
double 9 and 90. Okay. Now, let us go to console and
go to check the proper go panjas
let us pass double 9, double 9 Tomcat application should get.
Oh, he taught me. Okay. 80, 80 portal on the bar. The
88 double n again.
Go to insert mode and what is the example for here, the
syntax.
Copy this syntax, go back to terminal, just paste it. Now, press
escape, WQ save and
click it. Now, let us run this containers. So, how to run
the container? Just you need
to say Docker compose space up, I find D. Now, it is
pulling all those images and we can
access it giving the, what, double 4, double 4, 5 9 0
1 for V and C and 5 9 0 2, Firefox
image was pulled from container started. So, just use the command Docker
containers
LS to see all the containers they are working fine or not.
So, now, let us copy the public
IP and test all our applications are working properly or not. So,
what is the first port?
Double 4, double 4. So, just give here double 4, double 4,
the center. You can see Selenium
grid interface successfully and next, what is the next port? On spatical
port, type in
the router, just remove all the containers. To remove all the containers,
just pass this
command. So, network, I will check, check, check, check, check, check, check.
So tomorrow
class I will tell you, I will go time to troubleshoot it.
So, all the containers stopped
and you can stop your instance also. So, there are doubts on
the aragandic glass law,
later on, I will add this session. No, it's not flat, it's
just him. Please do practice.
