Write a Docker Compose File

Write a Docker Compose File

Task :

The Nautilus application development team shared static website content that needs to be hosted on the 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. 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/security volume of docker host which is already there. (please do not modify any data within these locations).

Solution :

[email protected]_host /$ ssh [email protected]
The authenticity of host 'stapp03 (172.16.238.12)' can't be established.
ECDSA key fingerprint is SHA256:fScMzeTcteVfkLAnmpPdXmrGM5WYkyzbNZcAoJ1TX8s.
ECDSA key fingerprint is MD5:f2:64:de:d5:d9:ac:d3:7f:04:1b:bf:83:22:e0:2d:2d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'stapp03,172.16.238.12' (ECDSA) to the list of known hosts.
[email protected]'s password: 
[[email protected] ~]$ cd /opt/docker/
[[email protected] docker]$ vi docker-compose.yml
[[email protected] docker]$ sudo vi docker-compose.yml

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for banner:

version: "3.3"
services:
  httpd:
    image: httpd:latest
    container_name: httpd
    ports:
      - "8088:80"
    volumes:
      - /opt/security:/usr/local/apache2/htdocs

[[email protected] docker]$ sudo docker-compose up
Creating network "docker_default" with the default driver
Pulling httpd (httpd:latest)...
latest: Pulling from library/httpd
f7ec5a41d630: Pulling fs layer
f7ec5a41d630: Downloading [> ] 277.5kB/27.14MB
8d28: Downloading [> ] 29.17kB
f7ec5a41d630: Downloading [========> ] 4.471MB
f7ec5a41d630: Pull completed
1589b6d8645: Pull complete
83d3755a8d28: Pull complete
3b7daa309abc: Pull complete
fb83e95a0ade: Pull complete

Digest: sha256:79c67705b322b8284080d80fc825275d05ca48c5637a7302d3d92b79127b8df6
Status: Downloaded newer image for httpd:latest
Creating httpd ... done
Attaching to httpd
httpd | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.2. Set the 'ServerName' directive globally to suppress this message
httpd | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.2. Set the 'ServerName' directive globally to suppress this message
httpd | [Thu May 06 14:23:22.049480 2021] [mpm_event:notice] [pid 1:tid 139727774168192] AH00489: Apache/2.4.47 (Unix) configured -- resuming normal operations
httpd | [Thu May 06 14:23:22.049580 2021] [core:notice] [pid 1:tid 139727774168192] AH00094: Command line: 'httpd -D FOREGROUND'
httpd | [Thu May 06 14:23:41.767003 2021] [mpm_event:notice] [pid 1:tid 139727774168192] AH00492: caught SIGWINCH, shutting down gracefully
httpd exited with code 0

Leave a Reply

Your email address will not be published. Required fields are marked *