Jenkins is an open source DevOps tool build mainly for the purpose of continuous integration continuous delivery. It has recently become very popular in the DevOps world for its wide range of plugins. While it does not eliminate the need to define steps or create scripts to deploy the builds to test, staging and production environments but it definitely automates a lot of things fetching source code from gitlab, bitbucket, github and other sources and triggering automated builds. Jenkins support almost 1400 plugins which has become really attractive for its growing community. On top automated build triggers are a real catch for the DevOps engineers who have to this manually. Automated webhooks can be called and post build triggers can be configured which are really helpful.
These are just a handful of benefits of Jenkins among many others. Exploring Jenkins is itself a job. Here we will explain how to run Jenkins with docker.
Prerequisites
Following are the prerequisites to follow this tutorial.
- Ubuntu 18.04 host machine
- Docker installed and running.
Following the tutorial doesn’t require any prior knowledge of Socker or Jenkins.
How to Run Jenkins Container
Open Source Jenkins Docker Image is hosted on Docker Hub. we run the following command, docker tries to find the Jenkins image on local machine and if it is not present it will by default look for it on Docker Hub, pull it from there and run the container. -p 8080:8080 -p 5000:5000 options are mapping docker containers 8080 and 5000 ports to local machines 8080 and 5000 ports respectively. It is done so we could access Jenkins directly from host machine’s ip address and to allow traffic move in and out of container.
$ sudo dockerrun-p 8080:8080 -p 50000:50000 Jenkins
Saving Jenkins Data with Docker Volumes
Following command will also save all the Jenkins data to your host machine in addition to mapping ports. Give the absolute path of your host machine where you want to save Jenkins data on host machine before colon “: ” and path after the colon is the path where the Jenkins data is stored inside the container.
Actually, there will be only one copy of data, but it will be available on different paths from outside and inside the container. Also make sure the path where data is being stored on the host machine, all those directories are accessible to Jenkins user.
$ sudo dockerrun-p 8080:8080 -p 50000:50000 -v /your/home:/var/Jenkins_homeJenkins
Congratulations! You have successfully installed and have Jenkins up and running with docker.
How to Access Jenkins
Run the following command to confirm that your jenkins container is in running state. This command outputs a list of all running containers on a machine.
$ sudo dockerps
If Jenkins is listed in the output list, its ready to accessed.
You have Jenkins running on port 8080. You can access Jenkins with your machine’s ip address (or if you have domain name for your server, than that) followed by port 8080 remotely or localhost followed by port 8080 from your host machine.
It will redirect you to the login page and you are good to go and explore jenkins.
Conclusion
Jenkins is really easy to install with docker. With just one command you can install and have Jenkins running, otherwise it would take more steps to install and run jenkins.
Check out these top 3 Best web hosting services
- To end your queries about Top web hosting, simply click on this link.