TASK 141: Docker EXEC operations
Requirements
One of the Nautilus DevOps team members was working to configure services on a kkloud container that is running on App Server 2 in Stratos Datacenter. Due to some personal work he is on PTO for the rest of the week, but we need to finish his pending work ASAP. Please complete the remaining work as per details given below:
a. Install apache2 in kkloud container using apt that is running on App Server 2 in Stratos Datacenter.
b. Configure Apache to listen on port 3003 instead of default http port. Do not bind it to listen on specific IP or hostname only, i.e it should listen on localhost, 127.0.0.1, container ip, etc.
c. Make sure Apache service is up and running inside the container. Keep the container in running state at the end.
This page preserves the original task statement and uses one direct container-shell workflow with docker exec to apply the Apache changes.
Prerequisites
- You can SSH to App Server 2 and switch to a privileged shell.
- The container kkloud is already running on the host.
- The container image supports
aptand contains the standard Apache configuration paths used in the steps.
Steps
Login to the app server and switch to root. For the server credentials, check out the Project Nautilus documentation.
sshpass -p '**********' ssh -o StrictHostKeyChecking=no steve@172.16.238.11
sudo su -
**********
Check the running containers.
[root@stapp02 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82af27e0946b ubuntu:18.04 "/bin/bash" 2 minutes ago Up 2 minutes kkloud
Open a shell to the container using the exec command.
docker exec -it kkloud /bin/bash
While inside the container, install the necessary packages and configure the required settings based on the instructions.
apt install apache2 -y
cd /etc/apache2
sed -i 's/Listen 80/Listen 3003/g' ports.conf
sed -i 's/:80/:3003/g' apache2.conf
sed -i 's/#ServerName www.example.com/ServerName localhost/g' apache2.conf
While still inside the pod, restart the service and verify status.
service apache2 start
service apache2 enable
service apache2 status
Verification
- Confirm the container is still running with
docker ps -a | grep kkloud. - Inside the container, confirm Apache is listening on port 3003 by reviewing the updated configuration files.
- Confirm the Apache service reports a running state with
service apache2 status.