## Task 41 As per recent requirements shared by the Nautilus application development team, they need custom images created for one of their projects. Several of the initial testing requirements are already been shared with DevOps team. Therefore, create a docker file /opt/docker/Dockerfile (please keep D capital of Dockerfile) on App server 1 in Stratos DC and configure to build an image with the following requirements: a. Use ubuntu:24.04 as the base image. b. Install apache2 and configure it to work on 3000 port. (do not update any other Apache configuration settings like document root etc). ```bash ssh tony@stapp01 sudo mkdir -p /opt/docker sudo tee /opt/docker/Dockerfile > /dev/null <<'EOF' FROM ubuntu:24.04 # install apache2 non-interactively RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 && \ apt-get clean # configure apache to listen on port 3000 RUN sed -i 's/^Listen 80$/Listen 3000/' /etc/apache2/ports.conf && \ sed -i 's///' /etc/apache2/sites-enabled/000-default.conf EXPOSE 3000 CMD ["apache2ctl", "-D", "FOREGROUND"] EOF ``` ## Task 42 The Nautilus DevOps team needs to set up several docker environments for different applications. One of the team members has been assigned a ticket where he has been asked to create some docker networks to be used later. Complete the task based on the following ticket description: a. Create a docker network named as news on App Server 3 in Stratos DC. b. Configure it to use macvlan drivers. c. Set it to use subnet 192.168.30.0/24 and iprange 192.168.30.0/24. ``` ```bash ssh banner@stapp03 # BigGr33n docker network create -d macvlan \ --subnet 192.168.30.0/24 \ --ip-range 192.168.30.0/24 \ news docker network inspect news ``` ## Task 43 The Nautilus DevOps team is planning to host an application on a nginx-based container. There are number of tickets already been created for similar tasks. One of the tickets has been assigned to set up a nginx container on Application Server 3 in Stratos Datacenter. Please perform the task as per details mentioned below: a. Pull nginx:alpine docker image on Application Server 3. b. Create a container named demo using the image you pulled. c. Map host port 3000 to container port 80. Please keep the container in running state. ```bash ssh banner@stapp03 # BigGr33n # a. pull the image docker pull nginx:alpine # b + c. run named container, map host 3000 → container 80, detached docker run -d --name demo -p 3000:80 nginx:alpine ``` ## Task 44 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 3003 of docker host. d. Map container's /usr/local/apache2/htdocs volume with /opt/itadmin volume of docker host which is already there. (please do not modify any data within these locations). ```bash ssh banner@stapp03 # BigGr33n sudo mkdir -p /opt/docker sudo tee /opt/docker/docker-compose.yml > /dev/null <<'EOF' version: "3" services: webserver: image: httpd:latest container_name: httpd ports: - "3003:80" volumes: - /opt/itadmin:/usr/local/apache2/htdocs EOF cd /opt/docker sudo docker compose up -d ``` ## Task 45 The Nautilus DevOps team is working to create new images per requirements shared by the development team. One of the team members is working to create a Dockerfile on App Server 2 in Stratos DC. While working on it she ran into issues in which the docker build is failing and displaying errors. Look into the issue and fix it to build an image as per details mentioned below: a. The Dockerfile is placed on App Server 2 under /opt/docker directory. b. Fix the issues with this file and make sure it is able to build the image. c. Do not change base image, any other valid configuration within Dockerfile, or any of the data been used — for example, index.html. Note: Please note that once you click on FINISH button all the existing containers will be destroyed and new image will be built from your Dockerfile. ```bash ssh steve@stapp02 # Am3ric@ sudo tee /opt/docker/Dockerfile > /dev/null <<'EOF' FROM httpd:2.4.43 WORKDIR /usr/local/apache2 RUN sed -i "s/Listen 80/Listen 8080/g" /usr/local/apache2/conf/httpd.conf RUN sed -i '/LoadModule\ ssl_module modules\/mod_ssl.so/s/^#//g' conf/httpd.conf RUN sed -i '/LoadModule\ socache_shmcb_module modules\/mod_socache_shmcb.so/s/^#//g' conf/httpd.conf RUN sed -i '/Include\ conf\/extra\/httpd-ssl.conf/s/^#//g' conf/httpd.conf COPY certs/server.crt /usr/local/apache2/conf/server.crt COPY certs/server.key /usr/local/apache2/conf/server.key COPY html/index.html /usr/local/apache2/htdocs/ EOF ``` ## Task 46 The Nautilus Application development team recently finished development of one of the apps that they want to deploy on a containerized platform. The Nautilus Application development and DevOps teams met to discuss some of the basic pre-requisites and requirements to complete the deployment. The team wants to test the deployment on one of the app servers before going live and set up a complete containerized stack using a docker compose fie. Below are the details of the task: On App Server 1 in Stratos Datacenter create a docker compose file /opt/finance/docker-compose.yml (should be named exactly). The compose should deploy two services (web and DB), and each service should deploy a container as per details below: For web service: a. Container name must be php_blog. b. Use image php with any apache tag. Check here for more details. c. Map php_blog container's port 80 with host port 8089 d. Map php_blog container's /var/www/html volume with host volume /var/www/html. For DB service: a. Container name must be mysql_blog. b. Use image mariadb with any tag (preferably latest). Check here for more details. c. Map mysql_blog container's port 3306 with host port 3306 d. Map mysql_blog container's /var/lib/mysql volume with host volume /var/lib/mysql. e. Set MYSQL_DATABASE=database_blog and use any custom user ( except root ) with some complex password for DB connections. After running docker-compose up you can access the app with curl command curl :8089/ For more details check here. Note: Once you click on FINISH button, all currently running/stopped containers will be destroyed and stack will be deployed again using your compose file. ```bash ssh tony@stapp01 # Ir0nM@n sudo su - sudo mkdir -p /opt/finance sudo tee /opt/finance/docker-compose.yml > /dev/null <<'EOF' version: "3.8" services: web: image: php:apache container_name: php_blog ports: - "8089:80" volumes: - /var/www/html:/var/www/html db: image: mariadb:latest container_name: mysql_blog ports: - "3306:3306" volumes: - /var/lib/mysql:/var/lib/mysql environment: MYSQL_DATABASE: database_blog MYSQL_USER: blog_user MYSQL_PASSWORD: Bl0g_P@ss2024 MYSQL_ROOT_PASSWORD: R00t_P@ss2024 EOF cd /opt/finance sudo docker compose up -d sudo docker ps # php_blog + mysql_blog, both Up curl http://localhost:8089/ ``` ## Task 47 A python app needed to be Dockerized, and then it needs to be deployed on App Server 3. We have already copied a requirements.txt file (having the app dependencies) under /python_app/src/ directory on App Server 3. Further complete this task as per details mentioned below: Create a Dockerfile under /python_app directory: Use any python image as the base image. Install the dependencies using requirements.txt file. Expose the port 3004. Run the server.py script using CMD. Build an image named nautilus/python-app using this Dockerfile. Once image is built, create a container named pythonapp_nautilus: Map port 3004 of the container to the host port 8096. Once deployed, you can test the app using curl command on App Server 3. ```bash ssh banner@stapp03 # BigGr33n sudo su - ls -la /python_app/src/ # confirm server.py + requirements.txt here tee /python_app/Dockerfile > /dev/null <<'EOF' FROM python:3.12 WORKDIR /python_app/src COPY src/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY src/ . EXPOSE 3004 CMD ["python", "server.py"] EOF cd /python_app docker build -t nautilus/python-app . docker run -d --name pythonapp_nautilus -p 8096:3004 nautilus/python-app docker ps curl http://localhost:8096/ ``` ### Task 48 The Nautilus DevOps team is diving into Kubernetes for application management. One team member has a task to create a pod according to the details below: Create a pod named pod-httpd using the httpd image with the latest tag. Ensure to specify the tag as httpd:latest. Set the app label to httpd_app, and name the container as httpd-container. Note: The kubectl utility on the jump-host has been configured to work with the Kubernetes cluster. ### Solution # Create pod-httpd ## Apply ```bash kubectl apply -f - <