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, run:
(If running Docker for Windows, please refer to Important section below)
docker run --name jenkins \
-v $(which docker):/usr/local/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
--privileged \
--user root \
-p 50000:50000 \
-p 8080:8080 \
-d \
jenkins/jenkins:lts
Command Section | Description |
---|---|
docker run |
Tells docker to going to run a container image |
--name jenkins |
Names the container being launched |
-v $(which docker):/usr/local/bin/docker |
Mounts the local docker executable to the Jenkins container, since docker is not installed in the container. |
-v /var/run/docker.sock:/var/run/docker.sock |
Mounts the local docker daemon socket to the Jenkins container. |
–privileged |
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 |
-d |
Runs the container process in the background |
jenkins/jenkins:lts |
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: |
Windows OS: When using Docker for Windows, use the following command to run the Jenkins container: docker run --name jenkins -v /usr/local/bin/docker:/usr/bin/docker -v //var/run/docker.sock:/var/run/docker.sock --privileged --user root -p 50000:50000 -p 8080:8080 -d jenkins/jenkins:lts You can run |
You can validate the container launched as expected by going to http://localhost:8080
.
You should see the Jenkins Startup Wizard:

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