- Ubuntu Server Linux with Docker installed.
Tip: I have installed a virtual machine using the image: “ubuntu-18.04.2-live-server-amd64”.
You can download it from https://www.ubuntu.com/download/server
Jenkins Docker image:
Docker has a lot of images ready to use. For example, if you search on Google “docker jenkins image”:
You will find the official Docker website to download Jenkins image:
And you can see the instruction to deploy the image in your Docker environment (:lts for latest version):
docker pull jenkins/jenkins:lts
This is only an example to understand how Docker images work.
Deploy Jenkins Docker image:
These are the commands to deploy a Jenkins image and run it as a container:
# Deploy Jenkins image [email protected]:~$ sudo docker pull jenkins/jenkins:lts # List current images [email protected]:~$ sudo docker images # Run a container using Jenkins image. # Note: this will automatically create a 'jenkins_home' docker volume on the host machine, that will survive the container stop/restart/deletion. [email protected]:~$ sudo docker run -d --name=jenkins_master -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
To see if your container is running you can execute the following:
[email protected]:~$ sudo docker ps
Jenkins Web Access:
URL to access Jenkins: http://192.168.152.132:8080
Tip: The IP of my Ubuntu virtual machine is 192.168.152.132
The first time you try to access to Jenkins web console, for security reasons you have to enter the password. That password was generated automatically during the installation.
To get the default password of your Jenkins installation, just execute the following command:
[email protected]:~$ sudo docker exec Jenkins-Master cat /var/jenkins_home/secrets/initialAdminPassword Password: 4b79afe3f62a458c903a8da29fce80af
And you can see now the welcome screen:
You can click now on Install suggested plugins to complete the installation or just click Select plugins to install manually.
Create your admin user:
Choose your Jenkins URL:
And now Jenkins is ready!
Tip: to run docker commands directly with your user instead using “sudo docker” you can execute the following command to add your user to docker group:
[email protected]:~$ sudo usermod -aG docker robermb # It's necessary to logout and login again with our user to apply the changes over the group: [email protected]:~$ logout
Update Jenkins (Docker)
Note: If you used an old or deprecated image version (e.g.: jenkins instead jenkins/jenkins), or you just have an old version of Jenkins you will need to update your Jenkins installation manually, following these steps:
These errors happened to me after the installation of an old image of Jenkins like version 2.60.3. To fix that is necessary to update Jenkins to 2.164.3 version.
Message: “New version of Jenkins (2.164.3) is available for download (changelog)”
- Right click on the download link and copy link address. (http://updates.jenkins-ci.org/download/war/2.164.3/jenkins.war)
- Log in into jenkins container:
# using host's root with -u 0 [email protected]:~$ sudo docker container exec -u 0 -it Jenkins-Master bash
- Download the update file, using the link you copied before:
[email protected]:/# wget http://updates.jenkins-ci.org/download/war/2.164.3/jenkins.war
- Move it to the correct place:
[email protected]:/# mv ./jenkins.war /usr/share/jenkins
- Change file permission:
[email protected]:/# chown jenkins:jenkins /usr/share/jenkins/jenkins.war
- Exit container (inside of your container):
[email protected]:/# exit
- Restart the container (from your Ubuntu server):
[email protected]:~$ sudo docker container restart Jenkins-Master
Now I’m only have some warnings but the errors have been fixed.
To fix that:
- Jenkins root url problem:
Go to Manage Jenkins -> Configure System -> Jenkins Location and complete the field “System Admin e-mail address” with your email.
- More Plugins problems:
Go to Manage Jenkins -> Plugin Manager and click on Download now and install after reboot.
- And now I only have a warning says “There are users who are still using a legacy API token….”:
Some interesting documentation: