The Nautilus application development team shared static website content that needs to be hosted on the httpd web server using a containerised platform. The team has shared details with the DevOps team, and we need to set up an environment according to those guidelines. Below are the details:
a. On App Server 3 in Stratos DC create a container named httpd using a docker compose file /opt/docker/docker-compose.yml (please use the exact name for file).
b. Use httpd (preferably latest tag) image for container and make sure container is named as httpd; you can use any name for service.
c. Map 80 number port of container with port 8088 of docker host.
d. Map container's /usr/local/apache2/htdocs volume with /opt/dba volume of docker host which is already there. (please do not modify any data within these locations).
Introduction
Welcome back to my 100 Days of DevOps journey! Today marks Day 44, and we're diving into Docker Compose – a powerful tool for defining and running multi-container Docker applications.
📋 Challenge Overview
The Nautilus application development team shared static website content that needs to be hosted on an httpd web server using a containerized platform. The team has shared details with the DevOps team, and we need to set up an environment according to those guidelines.
Task Requirements:
- On App Server 3 in Stratos DC
- Create a container named httpd using a docker compose file
/opt/docker/docker-compose.yml - Use httpd:latest image for the container
- Map port 80 of container with port 8088 of docker host
- Map container's
/usr/local/apache2/htdocswith host's/opt/dbavolume
🔧 Step-by-Step Solution
Step 1: SSH to App Server 3
ssh banner@stapp03
# Password: BigGr33n
Step 2: Switch to Root User
sudo su -
# Password: BigGr33n
Step 3: Create the Directory Structure
# Create the /opt/docker directory
mkdir -p /opt/docker
# Navigate to the directory
cd /opt/docker
Step 4: Install Docker Compose (if not already installed)
Docker Compose was not installed on the server, so I installed it:
# Download Docker Compose
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Grant execution permissions
chmod +x /usr/local/bin/docker-compose
# Verify installation
docker-compose --version
Output:
Docker Compose version v5.4.0
Step 5: Create the Docker Compose File
vi docker-compose.yml
Content:
version: '3'
services:
httpd-service:
image: httpd:latest
container_name: httpd
ports:
- "8088:80"
volumes:
- /opt/dba:/usr/local/apache2/htdocs
Step 6: Start the Container
docker-compose up -d
Output:
WARN[0000] /opt/docker/docker-compose.yml: the attribute `version` is obsolete
[+] up 9/9
✔ Image httpd:latest Pulled
✔ Network docker_default Created
✔ Container httpd Started
Step 7: Verify the Container
# Check container status
docker-compose ps
Output:
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
httpd httpd:latest "httpd-foreground" httpd-service 1 second ago Up Less than a second 0.0.0.0:8088->80/tcp
# Check with docker commands
docker ps | grep httpd
Output:
8f97bad02398 httpd:latest "httpd-foreground" 1 second ago Up Less than a second 0.0.0.0:8088->80/tcp httpd
# Check port mapping
docker port httpd
Output:
80/tcp -> 0.0.0.0:8088
80/tcp -> [::]:8088
Step 8: Test the Web Server
curl http://localhost:8088
Output:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Index of /</title>
</head>
<body>
<h1>Index of /</h1>
<ul><li><a href="index1.html"> index1.html</a></li>
</ul>
</body></html>
📋 Complete Commands Summary
# SSH to App Server 3
ssh banner@stapp03
# Password: BigGr33n
# Switch to root
sudo su -
# Password: BigGr33n
# Create directory
mkdir -p /opt/docker
cd /opt/docker
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3'
services:
httpd-service:
image: httpd:latest
container_name: httpd
ports:
- "8088:80"
volumes:
- /opt/dba:/usr/local/apache2/htdocs
EOF
# Install Docker Compose (if not installed)
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Start the container
docker-compose up -d
# Verify
docker-compose ps
docker ps | grep httpd
docker port httpd
curl http://localhost:8088
Top comments (0)