Installing Jenkins

The quickest way to get Jenkins running is with Docker, but you can also run the WAR file directly.

Syntaxdocker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

There are several ways to install Jenkins. The two most common for getting started are Docker and the standalone WAR file.

Option 1: Docker (recommended)

The official image gets you a working Jenkins in one command. Mapping a volume keeps your configuration when the container restarts.

Option 2: WAR file

Jenkins ships as a single jenkins.war Java archive. If you have Java installed you can run it directly with java -jar.

Option 3: Native packages

Linux users can install via apt or yum from the Jenkins package repositories, which sets it up as a system service.

Example

Example · bash
# Run Jenkins with Docker and persist its data in a named volume
docker run \
  --name jenkins \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins_home:/var/jenkins_home \
  jenkins/jenkins:lts

# --- OR run the WAR file directly (needs Java 17+) ---
java -jar jenkins.war --httpPort=8080

When to use it

  • A developer spins up Jenkins locally with one Docker command to test a Jenkinsfile without touching a shared server.
  • A DevOps team mounts a named volume so that restarting or upgrading the Jenkins container keeps all job history.
  • A CI team runs Jenkins in Docker Compose alongside dependency services for an isolated lab environment.

More examples

Basic Jenkins Docker run

Starts Jenkins detached with the web UI on 8080, agent port 50000, and data persisted in a named volume.

Example · bash
docker run --name jenkins \
  -d \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins_home:/var/jenkins_home \
  jenkins/jenkins:lts

Jenkins with Docker socket mount

Mounts the Docker socket so the Jenkins container can run Docker commands inside pipelines.

Example · bash
docker run --name jenkins \
  -d -p 8080:8080 \
  -v jenkins_home:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkins/jenkins:lts

Jenkins via Docker Compose

Defines a Jenkins service in Docker Compose with a persistent named volume for reproducible local setups.

Example · yaml
version: '3.8'
services:
  jenkins:
    image: jenkins/jenkins:lts
    ports:
      - '8080:8080'
      - '50000:50000'
    volumes:
      - jenkins_home:/var/jenkins_home
volumes:
  jenkins_home:

Discussion

  • Be the first to comment on this lesson.