0% found this document useful (0 votes)
12 views

Docker Compose

Uploaded by

Chiran Govinna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Docker Compose

Uploaded by

Chiran Govinna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CO515-2024 : Advances in Computer

Networks: Selected Topics


Objective: The objective of this lab exercise is to familiarize undergraduate students
with Docker Compose, a tool used for defining and running multi-container Docker
applications.

Prerequisites:

• Basic understanding of Docker and containers.


• Docker installed on the system.

Lab Exercise: In this exercise, students will create a basic multi-container application
using Docker Compose. The application will consist of two services: a web server and
a database.

Instructions:

1. Setup:
o Make sure Docker is installed on your system.
o Create a new directory for your project.
o Inside the project directory, create two files: Dockerfile and docker-
compose.yml .
2. Create Dockerfiles:
o Write Dockerfiles for both services (web server and database).
o For example, for a simple Node.js web server:

3. Write docker-compose.yml:
o Create a docker-compose.yml file to define the services.
o Here's an example for a Node.js web server and a MongoDB database:
4. Build and Run the Application:
o Run the following command in the project directory to build and run
the application:

docker-compose up
o This command will start both services defined in the docker-
compose.yml file.
5. Access the Application:
o Access the web server from a web browser at
http://localhost:3000 .
o You can interact with the application to see how it communicates with
the database.
6. Cleanup:
o After you're done, stop the running containers by pressing Ctrl + C .
o Optionally, you can run docker-compose down to remove the
containers.

Discussion Questions:

• What is Docker Compose, and how does it differ from Docker?


• What are the benefits of using Docker Compose for multi-container
applications?
• Explain the purpose of each section in the docker-compose.yml file.
• What are some real-world scenarios where Docker Compose can be useful?
• Submit the report in one week time.

You might also like