Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Do you want to set up a Jenkins server but avoid the pain of manual installation? You can achieve this by installing Jenkins on Ubuntu using the Jenkins Docker container!

This is a hands-on walkthrough of the steps to install Docker, start a Jenkins container, open port 8080, and complete the initial Jenkins configuration.

Let’s do this!

Step 1: Install Docker on the Ubuntu Server

The beauty of running apps as containers is that you do not need to install too much software. If you’re containerizing with Docker, all you need to install is Docker!

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Follow these steps to complete the first task of setting up Jenkins on an Ubuntu server with the official Jenkins Docker Container:

#1 Best Overall
Tecmojo 6U Wall Mount Server Cabinet IT Network Rack Enclosure Lockable Door and Side Panels Black, Cooling Fan, Standard Glass Door, 450mm Depth, for 19” IT Equipment, A/V Devices
  • Save valuable floor space: 6U wall mount server cabinet Dimensions: 13.78" H x21.65" W x17.72" D.Maximum mounting depth is 14.2"
  • Keep critical network equipment secure: glass door and side panels are lockable to prevent unauthorized access. Front door can be installed on either side of the front of the cabinet to satisfy your door swing orientation preference
  • Easy equipment configuration: Fully adjustable mounting rails and numbered U positions, with square holes for easy equipment mounting with top and bottom punch-out panels for easy cable access
  • Durability: Made of high quality cold rolled steel holds up to 110lb (50kg) (Easy Assembly Required)
  • PCI & HIPPA and EIA/ECA-310-E compliant
  1. As a standard practice, always update the app manager by running the “apt update”
sudo apt update
  1. After updating the Ubuntu app manage, execute “docker” to get the command you need to install the app.
When you run “docker,” since the app is not installed, Ubuntu returns a list of commands you can execute to install it.
How to Install Jenkins on Ubuntu with a Docker Container - Install Docker with the 'sudo apt install docker.io' command

I will run the command below (highlighted in the above screenshot) – to install Docker on my Ubuntu server;

sudo apt install docker.io

When you execute the command, you will be prompted to enter the root password. If you’re new to Linux and wondering why; it is because of the use of “sudo” in the command.

Moving on, after entering the root password, the installer will prompt you to confirm the installation. Type “Y” and press enter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wait for Docker to install, then proceed to step 2 below. Before you proceed, confirm that Docker is now installed by executing the “docker” command.

confirm that Docker is now installed by executing the "docker" command.

Since Docker is now installed, it displays information containing some details about the command.

Step 2: Start the Jenkins Container with a Docker Volume

Step 2: Start the Jenkins Container with a Docker Volume

After installing Docker on your Ubuntu Server, the next step to configuring Jenkins is to start the Jenkins container with a Docker Volume.

Wondering why we need to start the Jenkins container with a Docker Volume? Data changes in a Docker container are NOT persistent – meaning that if an app running as a container makes some changes, when the container restarts, it loses the data. To stop this from happening, you use a Docker Volume to sync the data on the container to a specified directory on the host (in this example, the Ubuntu server) – more on Docker Volumes later.

To start a Jenkins container on your Ubuntu Server using its official Docker image, execute the command below:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo docker run -p 8080:8080 -p 50000:50000 -d \
-v jenkins_home:/var/jenkins_home \ 
-v /var/run/docker.sock:/var/run/docker.sock \
jenkins/jenkins:lts
If the command fails to run in one go, copy and paste line by line. After pasting the first line, type “\” and press enter, then copy and paste the next line. Finally, hit the enter key to run the command.

Here are the explanations of the command and its parameters:

docker run – this is the Docker command you use to start a Docker container from an image

-p 8080:8080 – the “-p” switch is used to map the port the app’s container is running on to the host’s port. In this example, the first port 8080 represents the port on the host (my Ubuntu server).

Likewise, the second port 8080 is the container’s app. Notably, to access Jenkins via a browser, you use port 8080.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

So, -p 8080:8080 means “map the container’s port 8080 to the host’s port 8080.” Note that the two ports do not have to be the same.

For example, if port 8080 was not available on my host, I could have used -p 8081:8080 – this would map the Jenkins port 8080 to the host’s port 8081.

-p 50000:50000 – this switch is optional but I included it for completeness. However, in production environments, this may be required, and here is why:

If you need a Jenkins server for a large workload, you may need to configure Jenkins clusters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Port 50000 is the port where the master and worker Jenkins nodes communicate. So, it is essential to map the port to the host as well.

-d – this switch makes Docker run the Jenkins container in “detached” mode. This means that the Jenkins container process runs in the background.

Rank #2
AxcessAbles 12U Network Rack with Wheels - 500lb Capacity, 18" Depth | 19-Inch Open Frame AV Rack Case with 3” Caster Wheels | Screws, Spacer, Tool Included
  • Universal 19” Rack Mount Compatibility – Perfect for pro audio, video, IT, and network gear. Compatible with mixers, routers, patch panels, servers, power amps, and more.
  • Heavy-Duty Load Capacity – Built to support up to 550 lbs. Ideal for studio gear, DJ setups, server equipment, and AV components that demand serious stability.
  • Robust Steel Frame & Design – Made with 1.5mm thick steel and weighs 36 lbs for maximum durability, reduced vibration, and long-term reliability in any setting.
  • Mobile & Secure – Preinstalled with 3” industrial-grade caster wheels (lockable), making it easy to move and position your rack exactly where you need it.
  • All-In-One Setup Kit Included – Comes with 34 rack screws (5mm & 6mm), a 1U blank spacer, and an assembly tool—ready for fast installation out of the box.

Setting up the Jenkins Docker container this way in an Ubuntu server – or any OS – allows you to close the terminal without stopping the container’s process.

-v jenkins_home:/var/jenkins_home – you guessed it, the “-v” stands for volume! Earlier, I explained that to persist data on the Jenkins container, you must add a Docker volume.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“jenkins_home” is the name of the Docker volume that the data on the container is synched – more on this later. However, the “/var/jenkins_home” is the path a Jenkins Docker container saves data.

By specifying “-v jenkins_home:/var/jenkins_home,” I’m asking Docker to create a Volume on my Ubuntu server and sync the container’s data on the path /var/jenkins_home to the same path on the host.

-v /var/run/docker.sock:/var/run/docker.sock – this line of code mounts the path to the Docker binaries on the host server (where we already installed Docker) to the Jenkins container.

This is a very easy way to make Docker available on the container without needing to install it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

jenkins/jenkins:lts – this is the name of the Jenkins Docker image. The first part (before the “:”) is the image name.

Meanwhile, the second part (“lts”) is the “tag” or version of the image you want to use. You can learn more about available tags on the Jenkins official Docker hub page.

Now that you understand the parameters of the command that installs Jenkins on Ubuntu by starting its Docker container, let’s run the command.

The command pulls the image in “Layers” from the Docker Hub – then, it starts the Jenkins container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
How to set up Jenkins on Ubuntu with a Docker Container - Step 2: Start the Jenkins Container with a Docker Volume

Before proceeding to the next step, let’s run some commands that give us information about the Jenkins container, starting with “docker ps”:

sudo docker ps

The ‘docker ps’ command confirms that the Jenkins container started successfully.

There are multiple of information about the container, but I like to highlight the ports. The ports “0.0.0.0:8080->8080/tcp, :::8080->8080/tcp” – the first is IPv4, while the second is IPv6 – indicates that the host’s port 8080 is mapped to the same port on the container.

Similarly, the values “0.0.0.0:50000->50000/tcp and :::50000->50000/tcp” are port mappings for Jenkins master and worker nodes.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Having reviewed the results of the “docker ps” command, let’s look at another important command that provides information about the Docker volume:

sudo docker volume inspect jenkins_home

The command displays useful information about the Docker volume, jenkins_home created when we started the Jenkins container. By the way, this type of Docker Volume is called a “Named” volume.

Back to the result of the last command, here is the screenshot.

Rank #3
Sale
StarTech 22U 4-Post Server Cabinet, 33in/83cm Deep, 1764lb (RK2236BKF) | 19in enclosed enterprise steel rack, Adjustable depth 5.7in-33in, Lockable vented doors, Casters & feet
  • ADJUSTABLE DEPTH: 4- Post 22U 19" server rack enclosure with 4 vertical rails and adjustable mounting depth 5.7" to 33.0" (14,4cm to 83,8cm); IT rack is compatible with various servers / switches / data / video / AV and other IT networking equipment
  • EASY SHIPPING AND ASSEMBLY: Enclosed 22U data rack cabinet ships compact flat-packed to avoid damage and facilitate installation; Include wheels & levelling feet to offer more stability; Home server rack cabinet is only 46.6in (118,3cm) in height
  • DESIGN AND VENTILATION: Half height server rack cabinet has lockable and removable door and side panels with vented top allowing airflow; 4 Post 19" rack with 1764lb (800kg) weight capacity (stationary); Computer cabinet rack is EIA/ECA-310-E Compliant
  • HARDWARE INCLUDED: Rolling home network rack includes rack mounting and equipment mounting hardware, such as 20 M6 cage nuts / screws, PVC cup washers; Front/rear doors and side panels Keys, 2x allen keys; Rack assembly hardware; Casters and leveling feet
  • THE IT PRO'S CHOICE: Designed and built for IT Professionals, this 22U IT Server Cabinet is backed for life, including free lifetime 24/5 multi-lingual technical assistance

I have highlighted the “Mountpoint” because this is where the Jenkins data is stored on the Ubuntu server (the container host). To display the information in the path, let’s run the “ls” command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ls /var/lib/docker/volumes/jenkins_home/_data

The command displays multiple files and directories but for now, I will like you to the “secrets” directory. This is because this folder has the initial password we need to sign in to Jenkins – more on this later.

Step 3: Confirm that Port 8080 is Open on the Ubuntu Server

Before you proceed with the demo in this section, you must install telnet on your PC and netstat on your Ubuntu server.

So far, we’ve covered two steps in deploying Jenkins on Ubuntu with the Jenkins Docker container.

In the process, we already established that Jenkins is available on port 8080. So, since Jenkins is on this port, we should be able to access it by entering “server IP address:8080” on the browser.

Before we do that though, let’s confirm that port 8080 is open on the server. First, from your computer, run the telnet command:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
192.168.0.96 is the IP address of my Ubuntu server while (as we already established), 8080 is the Jenkins port. If port 8080 is open, the connection should be established and you will see a blank screen.
telnet 192.168.0.96 8080

Another method to check that port 8080 is open is to view the app using the port on the Ubuntu server. To display this information, run the command below on your Ubuntu server:

sudo netstat -tulpn | grep :8080

The command confirms that our Jenkins Docker container is listening on port 8080 for IPV4 and IPV6 for all incoming connections.

Step 4: Complete the Initial Jenkins Configuration

Now that we have established that port 8080 is open on the Ubuntu server, it is time for the final step – completing the initial Jenkins configuration.

Follow the steps below to conclude the final stage of installing Jenkins on Ubuntu:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enter the IP address of the Ubuntu server, followed by “:8080” on the browser. In my example, the IP address of my Ubuntu server is 192.168.0.96, I’ll enter:

192.168.0.96:8080

And, boom, Jenkins is up! Well, not quiet.

How to Install Jenkins on Ubuntu with a Docker Container - initial Jenkins configuration page

The first page of the Jenkins configuration requires us to enter an Administrator password. Before you panic, Jenkins provided the path this password is saved – see the highlighted portion of my screenshot above.

If you recollect, I touched on this in step 2 when I discussed this command.

sudo ls /var/lib/docker/volumes/jenkins_home/_data

Wait a minute, but the path in the above command is different from the path in the initial Jenkins configuration page shown earlier!

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes, it is.

The path – /var/lib/docker/volumes/jenkins_home/_data – is the path the Docker volume on the Ubuntu server is mounted. However, /var/jenkins_home/ is the Jenkins directory on the container.

We can get our initial Jenkins administrator password from both paths, but for this guide, I’ll get the password from the volume mount point – /var/lib/docker/volumes/jenkins_home/_data.

So, let’s review the output of this command, once again:

sudo ls /var/lib/docker/volumes/jenkins_home/_data

As I mentioned earlier, the _data directory has a directory called “secrets.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
NavePoint 12U Server Rack Enclosure with Glass Door, Cooling Fan, Locks, & Removable Side Panels - 12U Wall Mount Network Cabinet 19 Inch Rack 17.7" Deep (450mm)
  • DURABLE BUILD: Constructed from high-quality Cold Rolled Steel, the NavePoint Consumer Series 12U network cabinet boasts a sturdy, welded frame. Fitting EIA standard 19” networking equipment, this server cabinet confidently supports up to 110 lbs, providing a resilient base for your vital IT gear and equipment
  • CONVENIENT DESIGN: This 12U cabinet features a reinforced, heat-treated, tempered glass front door with a security lock. Perfect for applications requiring both security and accessibility, its compact design of 17.72"L x 21.65"W x 24.42"H offers a practical solution for space-constrained settings.
  • EASY & CUSTOMIZABLE EQUIPMENT SET UP - The 12U IT cabinet, with removable side panels and security locks, offers customization at its finest. Whether it's for an efficient device or cable management, this data cabinet ensures secure, adaptable configurations that suit your networking server requirements
  • ENHANCED VENTILATION & SECURITY - Built-in fans and flow-through ventilation work to prevent overheating, ensuring optimal operation of your equipment. The reinforced, lockable tempered glass front door not only boosts security but also facilitates easy monitoring of installed equipment.
  • SAFETY & COMPLIANCE - All NavePoint products are built to industry standards.

This is the same “secrets” directory in the Jenkins configuration page.

Anyway, to retrieve the administrator password, use the cat command below:

sudo cat /var/lib/docker/volumes/jenkins_home/_data/secrets/initialAdminPassword

And there is your administrator password. Copy the password and paste it on the “Administrator password” field of the Jenkins “Getting Started.”

After you enter the password, click “Continue” to proceed with the initial Jenkins server setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On the next page, select the default, “Install suggested plugins.” Then, wait for Jenkins to install the plugins.

start Jenkins on Ubuntu with a Docker Container

After that, create the first Jenkins administrator.

Finally, confirm the Jenkins server URL and port and finish the initial setup.

deploy Jenkins on Ubuntu with a Docker Container
setup Jenkins on Ubuntu with a Docker Container

I hope that by following this guide you set up Jenkins on Ubuntu with a Docker Container successfully! If you did or have any questions, let us know with the comments form towards the end of this page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Step 5: Make Docker Command Available on the Jenkins Container

When I mounted the Jenkins container in step 2, I explained that this line – “-v /var/run/docker.sock:/var/run/docker.sock” – of the code mounted the path to the Docker binaries on the host to the same path on the Jenkins container.

However, to make Docker commands available on the container, there are some final tasks we need to perform.

If you’re wondering why we need Docker commands on the Jenkins container, it is to allow us to run Docker commands when we create Jenkins jobs.

To confirm that Docker commands are not available on the container, let’s sign in to the container as the normal jenkins user. This is done using the “docker exec” command.

However, since you require the container’s ID, run the “docker ps” command first to get it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo docker ps

Now, log in to the container and run the “docker” command

Now that we have confirmed that docker is not available on the Jenkins container, let’s fix that problem with these steps:

  1. Exit the container as the jenkins user and sign in as root with this command
sudo docker exec -u 0 -it bd3c208d8633 bash
The difference between the above command and the previous “docker exec” command is that this last one included the “-u 0” switch – “u” allows specifying a user and “0” is a root user in a Linux-based docker container.
  1. After signing in as root, execute this command:
curl https://get.docker.com/ > dockerinstall && chmod 777 dockerinstall && ./dockerinstall

The curl command fetches the latest version of Docker from the official site, https://get.docker.com, and saves it in the dockerinstall folder. Then, the chmod command sets the correct permission on the folder.

Finally, “./dockerinstall” command installs Docker on the container. Execute the command, wait for it to complete, and proceed to step 3.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Grant everyone “rw” permission to the /var/run/docker.sock file. Before you run the command below, execute “ls -l /var/run/docker.sock” – to see the current permission.
chmod 666 /var/run/docker.sock

Execute “ls -l /var/run/docker.sock” again to confirm that everyone now has “rw” permission. Here are my results.

  1. Finally, exit the container as root and log in as jenkins user – docker is now available on the container!

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.