2

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?

TinkerTank
  • 5,685
  • 2
  • 32
  • 41
Urr4
  • 611
  • 9
  • 26
  • Not an answer, but have you considered moving from Docker Toolbox to the newer [Docker for Windows](https://docs.docker.com/docker-for-windows/)? It uses a different hypervisor (HyperV instead of VirtualBox) and a different mechanism for exposing host files/directories to your container. – larsks Oct 30 '16 at 13:32
  • Isn't this only for Windows 10? i can't upgrade since it's a work laptop. – Urr4 Oct 30 '16 at 16:16
  • Can't help you there, but it looks as if @TInkerTank has you all covered :) – larsks Oct 30 '16 at 19:13

2 Answers2

1

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.

Rao
  • 20,781
  • 11
  • 57
  • 77
TinkerTank
  • 5,685
  • 2
  • 32
  • 41
  • Thanks, this helps me understand the problem. I don't know how to fix it without using Linux or Windows 10, but maybe i find a workaround. – Urr4 Oct 30 '16 at 16:25
1

I didn't manage to do this using the docker console, however it is possible using Kitematic in the Docker Toolbock. In the volumes tab, you can add local folders as volumes into the container. The Jenkins files appeared in the local folder as expected.

Urr4
  • 611
  • 9
  • 26