There are two ways to install Jenkins on a server

  1. Install Jenkins directly on OS
  2. Run Jenkins as a Docker container

To configure Jenkins as a Docker Container.

Steps:

Step 1: Launch an EC2 Instance

Screenshot 2026-07-28 211044.png

Step 2: Configure Security Group to allow access (SSH 0n port 22 for myself, and port 8080 general public)

Screenshot 2026-07-28 210908.png

Step 3: SSH into Ec2instance ssh -i "Test-Key.pem" [[email protected]](<mailto:[email protected]>)

Screenshot 2026-07-28 211855.png

Step 4: Update and upgrade sudo apt update && sudo apt upgrade

Screenshot 2026-07-28 212126.png

Step 6: Install docker sudo apt install docker.io

Screenshot 2026-07-28 212515.png

Step 7: Install Jenkins container using the command below

sudo docker run -p 8080:8080 -p 50000:50000 -d \
-v jenkins_home:/var/jenkins_home jenkins\jenkins:lts

Explanation of code: sudo - Root user access Docker run - Starts the container -p 8080:8080 - (for browser access to Jenkins Application) - exposes the Docker container on port 8080 and maps it to my host on port 8080 -p 5000:5000 - (for Jenkins Master and Worker node communication, so that Jenkins can be started as a cluster) -d - Run the container in detached mode/the background, so that when i quit the terminal, the container still runs. -v - Volume, for persisting/storing data jenkins_home - Name of the volume/storage folder :/var/jenkins_home - This is the location of the storage folder where the storage will be mounted jenkins\jenkins:lts - Name of the official Image with the Tag(lates)

Wen done pulling the Jenkins image, run sudo docker ps to show the running images.

Screenshot 2026-07-28 220002.png

This image above confirms our Jenkins server is running. So when we copy the Ip address of the Ec2 instance and check it on the browser, alongside the port number that was configured, we can now see the Jenkins UI. http://54.173.244.209:8080

Screenshot 2026-07-28 220323.png

Step 8: Accessing the Login Credentials. To access the login credentials, we will have to first enter the docker container to access the file. we run docker exec -t <container id> bash

Screenshot 2026-07-28 223809.png

Note, we are logged in as Jenkins user and not as root user. this adheres to the best practice to always run services as a dedicated user and not a root user.

Screenshot 2026-07-28 224013.png

Next is to setup first Jenkins user by filling out the user information.

Screenshot 2026-07-28 224557.png