Introduction
This hands-on lab is designed to provide you with a practical understanding of Docker by guiding you through the deployment of a simple web application. You'll gain firsthand experience in containerizing an application, illustrating Docker's core functionalities of building, running, and managing containers.
Objectives
Lab Steps
Step 1: Creating Your Web Application
mkdir simple-web-app
cd simple-web-app`
index.html file: nano index.html.<!DOCTYPE html>
<html>
<head>
<title>My Simple Web App</title>
</head>
<body>
<h1>Hello, Docker!</h1>
<p>Welcome to my simple web application deployed using Docker.</p>
</body>
</html>
CTRL+O, CTRL+X).Step 2: Writing the Dockerfile
simple-web-app directory, create a Dockerfile:nano Dockerfile
# Use nginx base image from Docker Hub
FROM nginx:alpine
# Copy the web application to the nginx server
COPY index.html /usr/share/nginx/html/index.html
# Expose port 80
EXPOSE 80
Step 3: Building Your Docker Image
docker build -t simple-web-app .
simple-web-app with the web application.Step 4: Running Your Docker Container
docker run -d -p 8080:80 simple-web-app
Step 5: Accessing Your Web Application
curl http://localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>My Simple Web App</title>
</head>
<body>
<h1>Hello, Docker!</h1>
<p>Welcome to my simple web application deployed using Docker.</p>
</body>
</html>
Summary
In completing this lab, you've successfully containerized and deployed a simple web application using Docker. Starting from writing a Dockerfile to building and running a Docker container, you've experienced the fundamental processes of working with Docker. This lab serves as a practical introduction to Docker, highlighting its potential to streamline application deployment. With these skills, you're well on your way to exploring more advanced Docker functionalities and architectures.