44/100 Write a Docker Compose File

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/finance volume of docker host which is already there. (please do not modify any data within these locations).

SSH as normal

sudo vi /opt/docker/docker-compose.yml

version: '3.8'
services:
  web:
    image: httpd:latest
    container_name: httpd
    ports:
      - "8088:80"
    volumes:
      - /opt/finance:/usr/local/apache2/htdocs
esc 
wq!

Explanation:
image: uses the official httpd image (latest tag by default).
container_name: ensures the container is named httpd.
ports: maps host port 8088 → container port 80.
volumes: maps host /opt/finance → container /usr/local/apache2/htdocs.