I'm trying to start jenkins in a docker container using Docker Toolbox on Windows 7.
I run
docker run --name jenkins -p 8080:8080 -p 50000:50000 -v "//C/Users/myname/.jenkins:/var/jenkins_home" jenkins
The jenkins starts up nicely, however there is nothing created under C:/Users/myname/.jenkins. I've created the folder but it stays empty.
When I now stop and remove the container and start it again, jenkins has lost everything I've done before.
What am I doing wrong?
With Docker Toolbox, docker images don't actually run 'on' your windows machine, but rather on a virtual machine that's created on your windows machine.
It seems that host mounted volumes do have some caveats with Docker Toolbox on windows. See for example:
Perhaps there are some hints here that can help you to get it to work.
If you do want the data to persist between containers, even after deleting the jenkins container, you can use a data-volume for the jenkins homedir. In that case you would start jenkins as following:
docker run --name jenkins -p 8080:8080 -p 50000:50000 -v "/var/jenkins_home" jenkins
This basically creates a separate docker container for the /var/jenkins_home directory, allowing you to delete / upgrade / etc the jenkins container without affecting your data.
Do make sure that you understand what's going on here though. Read: https://docs.docker.com/engine/tutorials/dockervolumes/
this is also mentioned in the jenkins docker-image documentation: https://hub.docker.com/_/jenkins/
Alternatively: Could it be acceptable to just 'stop' and 'restart' the container whenever you need it? - In that case, you don't need the host mounted directories. In that case, just omit the -v options. This does make it hard to back-up your data, or to use a newer jenkins image.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments