How to Run a Jenkins Container on Ubuntu 18.04

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.

How to Run a Jenkins Container on Ubuntu 18.04

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

HostArmada
$1.79 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Install and Configure Docker Compose On an Ubuntu 22.04 VPS or Dedicated Server

This tutorial will show you how to install and configure the most recent version
3 min read
David Malcom
David Malcom
Author

How to Setup a Docker Swarm Cluster on a CentOS 7 VPS or Dedicated Server

This how-to article will help you install and configure Docker Swarm on CentOS 7
5 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Use Docker Containers with AWS EC2

This tutorial will help you deploy Docker containers in AWS and leverage the pow
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Install a Jenkins Automation Server on Ubuntu 18.04

This tutorial will help you install the Jenkins Automation server on your Ubuntu
3 min read
David Malcom
David Malcom
Author
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top