9 LabExercise Jenkins Docker
9 LabExercise Jenkins Docker
Experiment Steps:
Step 1: Install Docker
Install Docker on your computer by following the instructions provided on the Docker website
(https://docs.docker.com/get-docker/).
Step 2: Create a Simple HTML Page
Create a directory for your web server project.
Inside this directory, create a file named index.html with a simple "Hello, Docker!" message. This
will be the content served by your Apache web server.
Step 3: Create a Dockerfile
Create a Dockerfile in the same directory as your web server project. The Dockerfile defines how
your Apache web server application will be packaged into a Docker container.
Dockerfile
Use an official Apache image as the base image
FROM httpd:2.4
# Copy your custom HTML page to the web server's document root
COPY index.html /usr/local/apache2/htdocs/
25
Step 5: Run the Docker Container
Start a Docker container from the image you built:
docker run -p 8080:80 -d my-apache-server
This command maps port 80 in the container to port 8080 on your host machine and
runs the container in detached mode.
Step 7: Cleanup
Stop the running Docker container:
docker stop <container_id>
Replace <container_id> with the actual ID of your running container.
Optionally, remove the container and the Docker image:
docker rm <container_id>
docker rmi my-apache-server