Running Jenkins 2.0 in Production with Docker.
Nothing to install, the only prerequisite is that you have Docker installed on the server.
Files persists onto the localhost server at /opt/jenkins_home
. This makes it resilient to reboots and it is easy to just backup this folder.
service jenkins start
docker logs -ft jenkins
You will see this log section. Copy this password:
2016-05-05T17:25:49.011787978Z *************************************************************
2016-05-05T17:25:49.011808021Z *************************************************************
2016-05-05T17:25:49.011814273Z *************************************************************
2016-05-05T17:25:49.011819429Z
2016-05-05T17:25:49.011824960Z Jenkins initial setup is required. An admin user has been created and a password generated.
2016-05-05T17:25:49.011834803Z Please use the following password to proceed to installation:
2016-05-05T17:25:49.011839910Z
2016-05-05T17:25:49.011845543Z e30bed7d3c104005aeadd45de3a60d37
2016-05-05T17:25:49.011850557Z
2016-05-05T17:25:49.011855603Z This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
2016-05-05T17:25:49.011860984Z
2016-05-05T17:25:49.011865623Z *************************************************************
2016-05-05T17:25:49.011871858Z *************************************************************
2016-05-05T17:25:49.011877088Z *************************************************************
Go to http://localhost
(or whatever the IP of the server is)
You will need the password to go through the setup.
Just backup the folder /opt/jenkins_home
. If you need to restore, just restore all of the contents to this location and start up Jenkins again.
You can backup the files to AWS S3 by running this Docker command:
docker run --env aws_key=<YOUR AWS KEY> \
--env aws_secret=<YOUR AWS SECRET> \
--env cmd=sync-local-to-s3 \
--env DEST_S3=s3://my.backup.bucket/jenkins_home/ \
-v /opt/jenkins_home:/opt/src/$(/bin/date +\%Y\%m\%d) \ garland/docker-s3cmd
You can also setup a cron job that uses the S3 backup on a schedule.
-
Edit your crontab
-
Add this entry in
0 22 * * * /usr/bin/docker run --env aws_key=<YOUR AWS KEY> --env aws_secret=<YOUR AWS SECRET> --env cmd=sync-local-to-s3 --env DEST_S3=s3://my.backup.bucket/jenkins_home/ -v /opt/jenkins_home:/opt/src/$(/bin/date +\%Y\%m\%d) garland/docker-s3cmd
This will perform a backup nightly.