Created
June 13, 2018 21:48
-
-
Save managedkaos/b869c2eef12345da1d431976ba350b0f to your computer and use it in GitHub Desktop.
Run Jenkins on Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jenkinsondocker() { | |
if [ $(ps -elf | grep docker | wc -l) -gt 0 ]; | |
then | |
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' http://127.0.0.1:49000) -eq 403 ]; do echo -n '.'; sleep 1; done | |
echo | |
echo -n "Here's the admin password! " | |
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword | |
echo "Browse to http://localhost:49000" | |
else | |
echo "Can't find any docker processes. Is Docker really running? :/" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this in your .bashrc and then run
you'll see: