Install Jenkins using Docker in Oracle Cloud

Sergey Yanover
2 min readApr 13, 2021

--

You may choose Oracle Cloud as a Cloud Infrastructure Provider.

We know Jenkins as a popular automation server which allows to create pipelines, build, test and deploy software. I’d like to install Jenkins based on docker image in Oracle Cloud. I am going to install Docker, Jenkins, Git on Oracle Linux.

1. Install Docker on Oracle Linux

I presume you already have Oracle Infrastructure, ssh access to a linux machine and opened ports 22, 8080 from outside. I have Oracle Linux 7.9 but you may have another version with similar actions.

yum update

Let’s check the file

ls -la /etc/yum.repos.d/oracle-linux-ol7.repo

It should be updated with a current date.

yum install docker-engine
reboot
systemctl enable docker
systemctl start docker
systemctl status docker.service
docker version
docker login

You have Docker on your cloud machine and you may login into DockerHub or another registry.

2. Install Jenkins on Oracle Linux

I use the link https://hub.docker.com/r/jenkins/jenkins

Instead of pulling the image we create Dockerfile:

mkdir jenkins
cd jenkins
touch Dockerfile
FROM jenkins/jenkins:lts-centosRUN /usr/local/bin/install-plugins.sh workflow-job &&\
/usr/local/bin/install-plugins.sh workflow-aggregator &&\
/usr/local/bin/install-plugins.sh credentials-binding &&\
/usr/local/bin/install-plugins.sh configuration-as-code &&\
/usr/local/bin/install-plugins.sh git
docker build -t jenkins .
docker images
docker tag jenkins oracle-docker-jenkins:v1

Some examples of using Jenkins you my find here:
https://github.com/jenkinsci/docker/blob/master/README.md

docker run -d -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home oracle-docker-jenkins:v1

In a console or inside the new container you might find a generated passsword. Also you can find the password in the host system:

cd /var/lib/docker/volumes/jenkins_home/_data/secrets/ 
ls initialAdminPassword

You would see the code like 5630f25d554547449bfa27d176fe07ca.

The other way to find this file is logging into the container:

docker ps
docker exec -it <container id> sh
cat /var/jenkins_home/secrets/initialAdminPassword

You should change the Ingress rule of your Security List in Oracle Cloud to port 8080 and restrict Source with your current public IP address.

Google displays your public IP address if you search “my ip address” or you can use some other services.
http://<server’s IP address>:8080/

3. Git on Oracle Linux

- Simple way to install the old Git version:

yum install git

- You may use Git in Docker :
https://hub.docker.com/r/alpine/git

docker pull alpine/git
docker run -ti — rm -v ${HOME}:/root -v $(pwd):/git alpine/git

You can add alias to the file /etc/bashrc or to /root/.bashrc

alias git=’docker run -ti — rm -v ${HOME}:/root -v $(pwd):/git alpine/git’

- I would compile and install specific Git version from sources:

yum update
yum remove git
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-CPAN perl-devel -y

You may find all versions here: https://mirrors.edge.kernel.org/pub/software/scm/git/

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.29.3.tar.gz
tar -xvzf git-2.29.3.tar.gz
cd git-2.29.3
./configure --prefix=/usr/local
make all
make install
echo “export PATH=$PATH:/usr/local/bin” >> /etc/bashrc
source /etc/bashrc
git --version

Your machine with Oracle Linux 7.9 is ready to work. You may use others machines as Nodes for Jenkins or add Cloud Plugins/Kubernetes to Jenkins and leverage its resources.

--

--