Using Jenkins on DC/OS backed by NFS

In the following blog, I am going to explain about how to use Jenkins on DC/OS and configure NFS for persistence storage. Jenkins on DC/OS works by running the Jenkins master as a one-instance Marathon application. Once the Jenkins master comes online, it registers itself as a Mesos framework (using the jenkins-mesos plugin).


I assume, you have running cluster of DC/OS on your machine. If not then follow my blog Install DC/OS on Vagrant to install and configure open source DC/OS on vagrant.

About NFS (Network File System) Mounts

NFS, or Network File System, is a distributed filesystem protocol that allows you to mount remote directories on your server. This allows you to leverage storage space in a different location and to write to the same space from multiple servers easily. NFS works well for directories that will have to be accessed regularly.

In my DC/OS cluster, I am running one master and two agent. You can check with vagrant status command:

$ vagrant status

Current machine states:

m1                        running (virtualbox) ===>
a1                         running (virtualbox) ===> 
a2                         running (virtualbox) ===>
p1                         running (virtualbox) ===>
boot                      running (virtualbox) ===>

We are going to configure NFS server on p1 VM that will works as NFS server for our a1 and a2 client.

p1 ==> NFS Server ==>
a1 ==> Client ==>
a2 ==> Client ==>


The system should be set up as root. You can access the root user by typing

$ sudo su

1. Setting Up the NFS Server(

a) Download the Required Software

Start off by using yum to install the nfs programs.

$ yum install nfs-utils nfs-utils-lib 

Subsequently, run several startup scripts for the NFS server:

$ chkconfig nfs on 
$ service rpcbind start
$ service nfs start

b)Export the Shared Directory

The next step is to decide which directory we want to share with the
client server. The chosen directory should then be added to the
/etc/exports file, which specifies both the directory to be shared and
the details of how it is shared. We are going to share the directory /jenkins_data.

We need to export the directory:

$ vi /etc/exports 

Add the following lines to the bottom of the file, sharing the directory with the client:

/jenkins_data ,sync,no_root_squash,no_subtree_check)
/jenkins_data ,sync,no_root_squash,no_subtree_check)

Once you have entered in the settings for each directory, run the following command to export them:

 $ exportfs -a 

2. Setting Up the NFS Client to Agent a1 ( and a2 (

a) Download the Required Software

Start off by using yum to install the nfs programs.

$ yum install nfs-utils nfs-utils-lib 

b) Mount the Directories
Once the programs have been downloaded to the the client server, create the directory that will contain the NFS shared files

$ mkdir -p /mnt/jenkins 

Then go ahead and mount it

$ mount /mnt/jenkins 

You can use the df -h command to check that the directory has been mounted. You will see it last on the list.

$ df -h

Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/centos-root      8.8G  3.1G  5.7G  35% /
devtmpfs                     739M     0  739M   0% /dev
tmpfs                        749M     0  749M   0% /dev/shm
tmpfs                        749M  8.3M  741M   2% /run
tmpfs                        749M     0  749M   0% /sys/fs/cgroup
/dev/sda1                    497M  164M  334M  33% /boot
none                         455G  164G  292G  36% /vagrant
tmpfs                        150M     0  150M   0% /run/user/501  8.8G  2.9G  6.0G  33% /mnt/jenkins

Additionally, use the mount command to see the entire list of mounted file systems.

$ mount

systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=28,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota)
none on /vagrant type vboxsf (rw,nodev,relatime)
tmpfs on /run/user/501 type tmpfs (rw,nosuid,nodev,relatime,size=153292k,mode=700,uid=501,gid=501) on /mnt/jenkins type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=,local_lock=none,addr=

You can ensure that the mount is always active by adding the directory
to the fstab file on the client. This will ensure that the mount starts
up after the server reboots.

$ vi /etc/fstab 

And add blow line:  /mnt/jenkins   nfs      auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

3. Testing the NFS Mount
Once you have successfully mounted your NFS directory, you can test that it works by creating a file on the Client and checking its availability on the Server.

Create a file in the directory to try it out:

$ touch /mnt/jenkins/example 

You should then be able to find the files on the Server in the /jenkins_data.

$ ls /jenkins_data 

4. Installing Jenkins backed by NFS
If you already have a mount point, great! Create an options.json file that resembles the following example:

$ cat options.json
    "jenkins": {
        "framework-name": "jenkins-prod",
        "host-volume": "/mnt/jenkins",
        "cpus": 2.0,
        "mem": 4096

Then, install Jenkins by running the following command:

$ dcos package install jenkins --options=options.json 

Jenkins will now be available with persistence storage.