Solutions Delivery Platform

Run the Jenkins Container

Docker simplifies packaging applications with all their dependencies.

Through Docker, we can have a running Jenkins instance in a matter of seconds.

In your terminal, first build a jenkins image with docker installed. Create a Dockerfile with the following:

FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
RUN curl -fsSL | apt-key add
RUN add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \
RUN apt-get update && apt-get install -y docker-ce docker-ce-cli

From the same directory as your Dockerfile, build the image:

docker build -t jenkins:lts-docker .

Running Jenkins as a docker container on a BAH managed machine requires specific certificates and tooling to be installed. A Dockerfile meeting these requirements can be built from the solutions-delivery-platform/bah-jenkins repo.

Then, to start jenkins, run:

(If running Docker for Windows, please refer to Important section below)

    docker run --name jenkins \
    -v /var/run/docker.sock:/var/run/docker.sock \
    --privileged \
    --user root \
    -p 50000:50000 \
    -p 8080:8080 \
    -d \
Table 1. Command Line Breakdown
Command Section Description

docker run

Tells docker to going to run a container image

--name jenkins

Names the container being launched jenkins. This is done for ease of referencing it later.

-v /var/run/docker.sock:/var/run/docker.sock

Mounts the local docker daemon socket to the Jenkins container.


Escalates the container permissions so it can launch containers on the host docker daemon

–user root

Runs the container as the root user so it can launch containers on the host docker daemon

-p 50000:50000

Port forwarding of the default JNLP agent port to our localhost

-p 8080:8080

Port forwading of the Jenkins Console port to our localhost


Runs the container process in the background


The container image from which to run this container

If port 8080 is already in use by another process then this command will fail. To run Jenkins on a different port, swap out the first 8080 to your desired port: <desired port number>:8080.

Windows OS: When using Docker for Windows, use the following command to run the Jenkins container:

    docker run --name jenkins \
    -v //var/run/docker.sock:/var/run/docker.sock  \
    --privileged \
    --user root \
    -p 50000:50000 \
    -p 8080:8080 \
    -d \

You can run docker logs -f jenkins to see the Jenkins logs. It will say "Jenkins is fully up and running" when Jenkins is ready.

You can validate the container launched as expected by going to http://localhost:8080.

You should see the Jenkins Startup Wizard:

jenkins initial password

In the next section, we’ll learn how to get past this Startup Wizard and configure the newly deployed Jenkins instance.