Question

Running Jenkins in Docker

Hi all,

I was wondering if anyone has ran Jenkins in a Docker container? How did you do it and are there any tips that you would share? What are the exact commands that you used to run the container with?

Thanks!

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hello,

Yes, I’ve recently had to set that up. So far it is working pretty well!

Here’s a link to the official Jenkins image on Docker Hub:

https://hub.docker.com/r/jenkins/jenkins

Note: Make sure NOT to use the deprecated one here:

https://hub.docker.com/r/_/jenkins

Once you have docker installed on your host, all you need to do is to simply run this command:

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

But even better, You will probably want to make that an explicit volume so you can manage it and attach to another container for upgrades:

docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

This will automatically create a ‘jenkins_home’ docker volume on the host machine, that will survive the container stop/restart/deletion.

For more information I would also suggest going through the readme file on the official repo here:

https://github.com/jenkinsci/docker/blob/master/README.md

Hope that this helps! Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.