Create a Container on Ubuntu & Install Apache2 on It — Docker Assignment 1
You have been asked to:
● Pull the Ubuntu image
● Create a container using Ubuntu, and map port 80 on the local
● Install apache2 on this container
● Check if you can access the Apache page on your browser
Git Hub Repository Link for Copy the Commands:
A. Pull Ubuntu Container
Step 1: Create an EC2 Instance First with Ubuntu Machine. Click on “EC2”.
Step 2: Click on “Instances (running)”.
Step 3: Click on “Launch Instances”.
Step 4: In “Name and Tags”, put “Name” as “Docker Assignment”.
Step 5: Choose “AMI” as “Ubuntu”.
Step 6: Remain “Instance type” as “t2.micro” & choose “key pair (login)” as “Proceed without a key pair (Not recommended)”.
Step 7: In “Network Settings”, choose Firewall (security groups)” as “Create security group”.
Tick the “Allow HTTP Traffic from the Internet” option to access the web page online.
Step 8: Click on “Launch Instance”.
Step 9: The instance will be launched successfully. Click on the hyperlink.
Step 10: Select the Instance & click on “Connect”.
Step 11: Again, click on “Connect”.
Step 12: Run the “sudo apt update” command to update the “Ubuntu” machine.
sudo apt update
Step 13: Install “Docker” using the “sudo apt-get install docker.io -y” command.
sudo apt-get install docker.io -y
Step 14: Access the docker by running the “sudo su –“ command as a “root user”.
sudo su -
Step 15: To check the version of the docker, type the “docker –version” command.
docker--version
Step 16: Check the docker status with the “systemctl status docker.io” command.
systemctl status docker.io
Docker is in an “Active” State.
Step 17: For pulling the “Ubuntu Image”, use “docker pull Ubuntu”. The docker image will be fetched from the docker directory.
docker pull ubuntu
Step 18: Type the “docker images” command to check the “Ubuntu” image. The “Ubuntu” image will be found.
docker images
B. Create a container using Ubuntu, and map port 80 on the local
Step 1: Run this command: “docker run -itd -p 80:80 — name test ubuntu” & it will create & do port mapping of a container.
docker run -itd -p 80:80 - name test ubuntu
Step 2: Run “docker container ls –a” & you will notice that the “test” container is mapped on port 80 successfully.
docker container ls -a
C. Install apache2 on this container
Step 1: Go inside the “test” container. Use this command: “docker exec –it test bash”.
docker exec -it test bash
Step 2: First run the “apt update” command to update the machine.
apt update
Step 3: Run the “apt install apache2” command to Install the apache2 web server.
apt install apache2
Step 4: Use the “service apache2 status” command to check the “Apache2” server status. “Apache2 is not running”.
service apache2 status
Step 5: Use this command: “service apache2 start” to start the server.
service apache2 start
Apache 2 will start after running this command. You can check the status using the “service apache2 status” command.
D. Check if you can access the Apache page on your browser
Step 1: Go to the “Instances” pages & click on “open address” in “Public IPv4 address”.
Step 2: The Apache web page will be successfully accessed.
More DevOps Resources:
DevOps Capstone Project 1 -Implementing a DevOps Lifecycle on a website using Docker & Jenkins Only
Launch a Container Using a New Image & Start Apache 2 Sevice Here — Docker Assignment 2
Pull the Image from Docker Hub & Install Apache2 on a Separate Machine — Docker Assignment 3
Replace the Apache Default Web Page With Sample HTML File Inside Container — Docker Assignment 5
Containerized an HTML Website using Docker on Production Environment — Docker Case Study