0
votes

I am playing around with docker and ran into an issue when mounting docker volumes with --mount instead of -v. It appears to me that the error popping up is not valid, but probably I am missing a small detail here.

The path to which I want bind the created image in the container is seen as not absolute in the --mount scenario.

I am running Docker on a windows 10 machine

I pulled the jenkins/jenkins:lts image and want to spin up 2 containers that use the same configuration. As said before I use this just to play around with docker, and am exploring how the volume system works.

What i did is create a docker volume that is used to share the configuarion.

docker volume create jenkins_cfg

Then I tried to run 2 containers. The first container started with:

docker run -d -p 8081:8080 --name jenkins2 -v jenkins_cfg:/var/jenkins_home jenkins/jenkins:lts

Which works fine..

The second container started with:

docker run -d -p 8085:8080 --name jenkin5 --mount source=jenkins_cfg,target=var/jenkins_home jenkins/jenkins:lts

This results in the error "C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'var/jenkins_home' mount path must be absolute. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'."

Also /var/jenkins_home is not working properly.

While the -v also asks for the same target folder , i would assume that this folder would also work in the target option of --mount. Probably, I am overlooking something here ...

2

2 Answers

1
votes

I figured out that the target folder should be preceeded by // so the docker command would look like

docker run -d -p 8085:8080 --name jenkin5 --mount source=jenkins_cfg,target=//var/jenkins_home jenkins/jenkins:lts

Still no clue why // has to be added, maybe someone can clarify on that one

0
votes

Actually mount binds are like mounting a part of physical disk volume to the containers. But volumes are like virtual memory you can't access them independently without containers but bind mounts can be accessed independently

Your mount binds should be an absolute path in your host

Hope this helps your cause