$ apt-get install docker (Ubuntu) $ yum install docker (RHEL/CENTOS)
$ docker pull jenkins
Step 3: Next, run a container using this image and map data directory from the container to the host; e.g in the example below /var/jenkins_home from the container is mapped to jenkins/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.
Mapping port 8080 on the host to the container (the web ui), port 50000 to port 50000 (for build agents). Run with
-p 50000:50000 so you can connect JNLP slaves. For port 50000. This is to handle connections from JNLP based build slaves. This will store the workspace in /var/jenkins_home. All Jenkins data lives in there including plugins and configuration.
$ docker run -d -p 8080:8080 -p 50000:50000 jenkins
$ docker run -d -p 8080:8080 -p 50000:50000 -u root -v $PWD/jenkins:/var/jenkins_home jenkins
docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins -u root
$ mkdir jenkins $ chown 1000 jenkins $ docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins
$ docker exec name tail -f /var/log/jenkins/jenkins.log Where name = --name