Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Run Jenkins on Docker
function jenkinsondocker() {
if [ $(ps -elf | grep docker | wc -l) -gt 0 ];
echo -n $(docker stop jenkins 2>&1) | sed 's/Error response from daemon://'
echo -n $(docker rm jenkins 2>&1) | sed 's/Error response from daemon://'
docker pull jenkins/jenkins:lts
docker run --detach --publish 49000:8080 --name jenkins jenkins/jenkins:lts
echo -n "Waiting for Jenkins process to start ."
until [ $(curl -o /dev/null --silent --head --write-out '%{http_code}\n' -eq 403 ]; do echo -n '.'; sleep 1; done
echo -n "Here's the admin password! "
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
echo "Browse to http://localhost:49000"
echo "Can't find any docker processes. Is Docker really running? :/"

This comment has been minimized.

Copy link
Owner Author

@managedkaos managedkaos commented Jun 13, 2018

Put this in your .bashrc and then run


you'll see:

lts: Pulling from jenkins/jenkins
cc1a78bfd46b: Already exists
d2c05365ee2a: Pull complete
231cb0e216d3: Pull complete
3d2aa70286b8: Pull complete
b621e52d9d65: Pull complete
f12314f6054a: Pull complete
f5ce6397976f: Pull complete
965859e0769b: Pull complete
4a76f2995e39: Pull complete
0de631c380d1: Pull complete
9d6752920dc9: Pull complete
c406b862fb45: Pull complete
540e374a8d0d: Pull complete
7be67aad290d: Pull complete
f6fd454b745e: Pull complete
ccc2b3edf0f8: Pull complete
28805657226a: Pull complete
3738af7c03c4: Pull complete
dab16bb6b3f9: Pull complete
aa4f9c274e44: Pull complete
5d8390d0a2de: Pull complete
Digest: sha256:30793c79d6f59467bb8b821a8bc96cda24a61397f54658adb25825c68f8d464f
Status: Downloaded newer image for jenkins/jenkins:lts
Waiting for Jenkins process to start ..........
Here's the admin password!   bebaee6349f74952a3ea062018aee52a
Browse to http://localhost:49000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment