Docker Compose 101 Notes
Docker Compose 101 Notes
com)
What is Docker-Compose?
pg. 1
Akshat ([email protected])
This tool can become very powerful and allow you to deploy
applications with complex architectures very quickly. I will give you a
concrete case study that will prove that you need it.
pg. 2
Akshat ([email protected])
Your solution offers two websites. The first allows stores to create their
online store in a few clicks. The second is dedicated to customer
support. These two sites interact with the same database.
Now that you know what docker-compose is going to be used for, it’s
time to create your first client/server-side application!
pg. 3
Akshat ([email protected])
pg. 4
Akshat ([email protected])
You should have this folder architecture in the following path ‘server/’:
.
├── Dockerfile
├── index.html
└── server.py0 directories, 3 files
pg. 5
Akshat ([email protected])
This code will allow you to create a simple web server inside this folder.
It will retrieve the content of the index.html file to share it on a web
page.
pg. 6
Akshat ([email protected])
• A ‘client.py’ file (python file that will contain the client code).
pg. 7
Akshat ([email protected])
Normally you should have this folder architecture in the following path
‘client/’:
.
├── client.py
└── Dockerfile0 directories, 2 files
This code will allow you to get the content of the server web page and
to display it.
pg. 8
Akshat ([email protected])
As for the server, we will create a basic Dockerfile that will be in charge
of executing our Python file.
4. Back to Docker-Compose
As you may have noticed, we have created two different projects, the
server, and the client, both with a Dockerfile.
So far, nothing has changed from the basics you already know.
pg. 9
Akshat ([email protected])
5. Build Docker-Compose
6. Run Docker-Compose
$ docker-compose up
There you go, that’s it. You should see “Docker-Compose is magic!”
displayed in your terminal.
As usual, I have prepared a list of orders that may be useful to you with
docker-compose.
pg. 10
Akshat ([email protected])
$ docker-compose down
• Lists containers.
$ docker-compose ps
• Lists images.
$ docker-compose images
pg. 11