Install Jenkins on Ubuntu and With Docker: Java 21, Unlock, Plugins, First Admin User and Reverse Proxy

CI CD Pipelines with Jenkins 30 min min read Updated: Nov 17, 2026 Beginner
Install Jenkins on Ubuntu and With Docker: Java 21, Unlock, Plugins, First Admin User and Reverse Proxy
Beginner Topic 2 of 3

Before You Install

ItemRecommendation
Operating systemUbuntu 22.04 or 24.04 (Debian, RHEL and Windows are also supported)
MemoryAt least 2 GB for learning, 8 GB or more for a busy server
DiskAt least 20 GB. Build history and workspaces grow
JavaA supported Java 21 (or 25) runtime. Check the official Java support policy for the exact versions of the Jenkins release you install
NetworkPort 8080 (default). Use HTTPS in front for real use
Why Java 21? Current Jenkins LTS lines require Java 21 or 25. Older guides that tell you to install Java 11 or 17 are out of date and the controller will not start with an unsupported Java version.

Option 1: Install on Ubuntu (apt)

bash # 1) Java sudo apt-get update sudo apt-get install -y fontconfig openjdk-21-jre java -version # 2) Jenkins LTS repository and key (check jenkins.io/doc/book/installing/linux for the current key file) sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null # 3) Install and start sudo apt-get update sudo apt-get install -y jenkins sudo systemctl enable --now jenkins sudo systemctl status jenkins --no-pager
PathPurpose
/var/lib/jenkinsJENKINS_HOME: configuration, jobs, plugins, secrets, workspaces. Back this up
/var/log/jenkins/jenkins.logMain log file
/etc/default/jenkins or the systemd unitPort and Java options (use systemctl edit jenkins)
/usr/share/java/jenkins.warThe application

The Setup Wizard

  1. Open http://SERVER-IP:8080
  2. Jenkins asks for the initial admin password. Read it from the server:
  3. Choose Install suggested plugins (Git, Pipeline, credentials and more) and wait
  4. Create the first admin user (use a real password; do not keep the temporary one)
  5. Confirm the Jenkins URL (for example https://jenkins.example.com/). Webhooks and links depend on it
bash sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Option 2: Run Jenkins in Docker

bash docker volume create jenkins_home docker run -d --name jenkins --restart unless-stopped \ -p 8080:8080 -p 50000:50000 \ -v jenkins_home:/var/jenkins_home \ jenkins/jenkins:lts-jdk21 docker logs -f jenkins # the initial admin password is printed here docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
yaml # compose.yaml services: jenkins: image: jenkins/jenkins:lts-jdk21 restart: unless-stopped ports: ["8080:8080", "50000:50000"] environment: JAVA_OPTS: "-Xmx1g -Djenkins.install.runSetupWizard=true" volumes: - jenkins_home:/var/jenkins_home volumes: jenkins_home: {}
  • Port 50000 is for inbound (JNLP/TCP) agents. If you only use WebSocket or SSH agents you can leave it closed
  • Always use a volume for /var/jenkins_home. Without it all jobs and settings vanish when the container is removed
  • To update: pull the new image, remove the old container and start it again with the same volume

Put HTTPS in Front With nginx

text server { listen 443 ssl; server_name jenkins.example.com; ssl_certificate /etc/ssl/certs/jenkins.crt; ssl_certificate_key /etc/ssl/private/jenkins.key; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; proxy_request_buffering off; # large artifact uploads proxy_read_timeout 90s; } }

After this, set the Jenkins URL to the HTTPS address under *Manage Jenkins, System*. If you see the warning *reverse proxy set up is broken*, the X-Forwarded-* headers or the Jenkins URL are wrong.

Tour of the Screen

AreaUse
DashboardList of jobs and the build queue and executors panels
New ItemCreate a job
Manage JenkinsSystem settings, plugins, nodes, security, tools, credentials, system log
Build HistoryAll builds across jobs
My ViewsGroup jobs into tabs
User menu (top right)Your API token, credentials and personal settings

Common Start-Up Problems

ProblemCause and fix
Service fails with Java errorWrong Java version. Install Java 21 and run sudo update-alternatives --config java
Cannot open port 8080Firewall or cloud security group. Allow TCP 8080 (or your proxy port)
Port 8080 in useAnother service. Change with systemctl edit jenkins and Environment="JENKINS_PORT=8081"
Please wait while Jenkins is getting ready foreverLow memory or plugin errors. Check journalctl -u jenkins -f
Plugin installation fails during the wizardNo internet access or proxy needed. Set the proxy in *Manage Jenkins, Plugins, Advanced*
Lost the admin passwordTemporarily disable security in config.xml (lab only), or use the script console from a recovery procedure, then set a new password

Practice Tasks

  1. Install Jenkins either on a VM or in Docker and finish the setup wizard
  2. Find JENKINS_HOME and list its folders
  3. Read the logs and find the version number
  4. Put nginx in front with a self-signed certificate and fix the Jenkins URL
  5. Restart Jenkins from the UI using /safeRestart and from the command line

Conclusion

Install a supported Java 21 runtime, add the official Jenkins LTS repository, start the service and complete the wizard with the initial admin password. In Docker, always mount a volume for /var/jenkins_home. For real use, put HTTPS in front with correct forwarded headers and set the Jenkins URL.

Quick Summary: Java 21; apt LTS repo; systemctl; initialAdminPassword; wizard; docker volume jenkins_home; ports 8080/50000; nginx headers; startup problems.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators