I am reading through this bit of the Jenkins Docker README and there seems to be a section that contradicts itself from my current understanding. https://github.com/jenkinsci/docker/blob/master/README.md

It seems to me that is says to NOT use a bind mount, and then says that using a bind mount is highly recommended? I'm confused.

NOTE: Avoid using a bind mount from a folder on the host machine into /var/jenkins_home, as this might result in file permission issues (the user used inside the container might not have rights to the folder on the host machine). If you really need to bind mount jenkins_home, ensure that the directory on the host is accessible by the jenkins user inside the container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run.

docker run -d -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts this will run Jenkins in detached mode with port forwarding and volume added. You can access logs with command 'docker logs CONTAINER_ID' in order to check first login token. ID of container will be returned from output of command above.

Backing up data

If you bind mount in a volume - you can simply back up that directory (which is jenkins_home) at any time.

This is highly recommended. Treat the jenkins_home directory as you would a database - in Docker you would generally put a database on a volume.

  • 1
    While I don't have time to read the full doc and get all the context, the first seems to be talking about bind mounting a folder and the second is talking about bind mounting a volume. My docker isn't that strong, but if I remember correctly, you can do a lot more by setting up and binding volumes than by binding folders directly to the host system.
    – Becuzz
    Jun 28, 2019 at 19:07
  • 1
    I have dockerized my fair share of Jenkins instances. In the long run, it’s just not worth the headaches. Just wait until you realize your dockerized Jenkins needs access to dockerd on the host to build other images.
    – RubberDuck
    Jun 28, 2019 at 23:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.