This repository contains a Dockerfile to build an Apache server image and instructions on how to run it using Docker.
- An AWS account to create an EC2 instance.
- Docker installed on your local machine. You can download Docker from https://www.docker.com/.
- AWS CLI installed on your local machine. You can download it from https://aws.amazon.com/cli/.
-
Open the AWS Management Console and navigate to the EC2 Dashboard.
-
Click on "Launch Instance" to create a new EC2 instance.
-
Follow the steps in the EC2 instance launch wizard, selecting an Amazon Machine Image (AMI), choosing an instance type, configuring instance details, adding storage, configuring security groups, and reviewing.
-
In the "Configure Security Group" step, make sure to add a rule to allow incoming traffic on port 80 (HTTP).
-
Launch the instance and download the key pair.
-
Connect to your EC2 instance using SSH:
ssh -i your-key-pair.pem ec2-user@your-instance-ip
Replace
your-key-pair.pem
with the path to your key pair file andyour-instance-ip
with your EC2 instance's public IP address.
-
Update the package list:
sudo yum update -y
-
Install Docker:
sudo amazon-linux-extras install docker sudo service docker start sudo usermod -a -G docker ec2-user
Note: You may need to re-login or run
su - ec2-user
to apply the group changes.
docker pull httpd
This command pulls the official Apache HTTP Server Docker image from Docker Hub.
docker run -d --name apache -p 80:80 httpd
-d
: Run the container in the background.--name apache
: Assign the name "apache" to the container.-p 80:80
: Map port 80 on the host to port 80 on the container.httpd
: The name of the Docker image.
Open your web browser and navigate to your EC2 instance's public IP address:
http://your-instance-ip
For example, if your instance's IP address is 54.123.456.789
, access the Apache server by navigating to http://54.123.456.789 in your web browser.
docker stop apache
docker rm apache
Replace apache
with the name you assigned to your container.
This project is licensed under the MIT License.