Setup a Jenkins Server on CentOS 7

1 minute read

How to setup a Jenkins Server on CentOS 7

Get Jenkins packages

# get packages
$ yum install java-1.8.0-openjdk.x86_64
$ wget -O /etc/yum.repos.d/jenkins.repo
$ rpm --import

Install packages

$ yum install -y jenkins docker vim git

Enable Firewall

$ firewall-cmd --zone=public --add-port=8080/tcp --permanent
$ firewall-cmd --zone=public --add-service=http --permanent
$ firewall-cmd --reload

Enable at Startup

$ systemctl start jenkins
$ systemctl enable jenkins

Login to web UI

$ http:// localhost or Ip address:8080

retrieve initial password

$ grep -A 5 password /var/log/jenkins/jenkins.log

Git working with proxy

git config –global http.proxy http://proxyuser:[email protected]:8080

Permissions for docker.sock

needs sudo setup (build into playbook) then selinux ‘chmod 777’ basically (fix this to be secure)

[[email protected] run]# setfacl -m u::rwx,g::rwx,o::rwx docker.sock
[[email protected] run]# getfacl docker.sock
# file: docker.sock
# owner: root
# group: root

Docker through Proxy (centos)

if you get this error:

+ docker pull ruby:2.3.1
Trying to pull repository ...
Pulling repository
Network timed out while trying to connect to You may want to check your internet connection or if you are behind a proxy.
[Pipeline] }

Edit /etc/sysconfig/docker and add the following lines:

HTTP_PROXY='http://user:[email protected]:proxy-port'
HTTPS_PROXY='http://user:[email protected]:proxy-port'

restart docker:

# systemctl restart docker

note: check ‘setenforce’ is set to ‘permissive’ (setenforce 0) so the docker.sock permissions dont get reverted on docker restart.

Docker image through a Proxy

commands in your image need to go through a proxy too (figure out how to redirect ALL docker traffic to proxy)

stage("Install Bundler") {
      sh "gem install -p bundler --no-rdoc --no-ri"

Running Docker images

need firewall rule: [[email protected] ~]# firewall-cmd --zone=public --add-port=4000/tcp --permanent

Publish Docker images to Private Registry

bootstrap of jenkins build needs keys setup to talk to registry


Jenkins on CentOS 7 Docker permissions Docker Proxy on Ubuntu