Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Deploy Jenkins in Docker as a container

1.Create Ec2 Instance and Security Group using Terraform


2. Connect to EC2 Instance using SSH
ssh -i < pem file> ec2-user@publicIP
3. Install Docker Server
yum install docker

4. By default Docker server does not start automatically, to start the


service run the below command
systemctl start docker
5. check the status of docker whether it is running or not
systemctl status docker
6. Take Jenkins Image from Docker hub and run as a container
docker run -d jenkins:2.60.3-alpine
7. To check the Docker Images run below command
docker images
docker ps
8. To access the container outside
docker run -d -p <host port: container port > < image : tag>
docker run -d -p 1001:8080 jenkins:2.60.3-alpine
You should get the Jenkins unlock page
9. Login to Container by using below command
docker exec -it <container-id> /bin/bash
10. Get the password of Jenkins
cat /var/jenkins_home/secrets/initialAdminPassword

11.Now Access the Jenkins UI using public IP and Host port


publicIP:Hostport
54.169.204.209:1001

You might also like