Bind entire volume to Windows Container in Docker - docker

I've mapped a network share to the X drive on the Docker host OS (Windows Server 2022). I'm trying to make this share available to containers running on this host.
Seems like this should be simple enough, but for reasons I cannot explain Docker just won't cooperate.
For testing, I tried:
docker run --rm -v c:\tools:c:\tools mcr.microsoft.com/dotnet/framework/sdk:4.8.1
This works as expected. Next I tried
docker run --rm -v x:\:x:\ mcr.microsoft.com/dotnet/framework/sdk:4.8.1
Which results in:
docker: Error response from daemon: invalid volume specification: 'x:\:x:\': invalid mount config for type "bind": bind source path does not exist: x:\.
I've tried the //x/ notation with similar results. Then I tried to use bind:
docker run --rm --mount 'type=bind,source=X:,target=X:' mcr.microsoft.com/dotnet/framework/sdk:4.8.1
Which results in
docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: X:.
Very annoying, since X: DEFINITELY exists.
How do I mount a different drive to a Docker container under Windows Server?

Related

Docker on a server: --mount type=bind or -v?

I've been trying to run a nextflow pipeline with a Docker image I've created on a server. I've tested this pipeline on my local client and it works fine but trying to run it on a server (ArchLinux, docker version 18.09.6) gives me many different errors. The problem is that the pipeline requires a huge database (NCBI:nt ~120GB) as an "input" (just read, not modify it). On the local client, I've used the temp flag for nextflow, which is equivalent to --mount type=volume,src=<src_path>,target=/tmp flag. This works perfectly on the local client. Once I've uploaded it to the server, I get different problems. I've been accessing the server using ssh (Window'sPowerShell and wsl2). I've tried using the following options:
Using --mount type=bind,src=<src_path>,target=/output:
I get the following error:
docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: <src_path>/. The same occurs if many different flags (e.g. readonly) or different propagation forms are used.
Using -v <src_path>:/output: A different error is given:
docker: Error response from daemon: error while creating mount source path '<src_path>': mkdir /share/library: permission denied.. I find this error quite unusual since my user does has the permissions to create files and directories in the src-path. Is there any way of forcing docker to use the permissions of my user?
Is --mount or -v even the right way of accessing this database from within the container? Any help or idea is always welcome since nothing I've found seems to bring me forward...
EDIT:
Rather than a "nextflow" question, it is more of a docker question, since running docker run <any_option_mentioned_above> <img_name>
returns the same errors.
This is the setup I've used to run nextflow processes inside docker containers:
main:
process mount_example {
label 'dockerised'
input:
file foo from bar
containerOptions "-v /path/to/source:/path/to/target/inside/docker/"
script:
"""
ls /path/to/target/inside/docker/
"""
}
and in config:
docker {
enabled = true
registry = 'yourdockerregister'
}
process {
withLabel: dockerised
{
container: yourdockerregistry
}
}
One of the features of a host mount that docker provides is it will create the folder if it doesn't already exist. Otherwise, when doing a bind mount in Linux, which is what this option is doing:
--mount type=bind,src=<src_path>,target=/output
Linux will not create the directory for you and the mount command will fail. To resolve you can switch back to a host mount, or create the directory in advance.

Docker run -v : Unable to mount a bind volume : "invalid volume specification"

I'm quite new to Docker. I'm running on Windows 10 Enterprise and am trying to containerize an existing app that runs on windows (so it's a Windows container). I don't know if this matters but the container is rather large (8 GB).
I need to share a config file (that lives on the host) with the container that the app will use when starting. I was thinking that a bind volume was simplest.
Problem: On running the image I get docker: Error response from daemon: invalid volume specification: '<source path>:<target path>'
Container was built with this command:
docker build -t my_image .
Here is the Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8
WORKDIR /app
COPY . .
ENTRYPOINT .\application.exe ..\Resources
Here is what I've tried
docker run -it -v c:/Users/my_user:/app my_image
I've tried every combination of C:/, C:\, C:\\, /c/, //c/, \c\, \\c\, etc.
I've tried multiple combinations of /app, //app, \app, \app, C:\app, etc.
I've also tried with and without :rw appended to the end
I've tried the ```--mount``` syntax which consistently outputs: docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: '/app'. (tried a bunch of variations of /app here too)
I've tried every possible combination (except the right one). Please help!
Since you are using a Windows container, your file path will change. Try the below command, from the docs Persistent Storage in Windows Containers
docker run -it -v c:\Users\my_user:c:\app my_image
If you are using a powershell and trying to run docker using docker run command you can try this approach. It worked for me in windows powershell (vs code powershell)
docker run -v ${pwd}\src:/app/src -d -p 3000:3000 --name react-app-c2 react-app-image
Here react-app-c2 is container name and react-app-image is image name
-v is for volume and ${pwd} is for current working directory
/app/src is for the containerdirectory.

docker: Error response from daemon: error while mounting volume '': VolumeDriver.Mount: 404 Not Found.(LINSTOR Docker Volume Plugin)

I am trying to use LINSTOR Docker Volume Plugin and I am able to create the volume but getting an error while mounting the volume.
docker run -itd --name=test -v lsvol:/data --volume-driver=linbit/linstor-docker-volume:latest ubuntu
8e02305a8fe63a0d6b99647e8fa7a532fa9cb3565e9bb04bab718b708382f0fe
docker:`enter code here` Error response from daemon: error while mounting volume '': VolumeDriver.Mount: 404 Not Found.
Mostly for reference since I wasn't able to find any information about this anywhere: LinSTOR was behaving correctly but the docker plugin lade/linstor:latest was giving me a 404 on mount, just like mentioned here.
Not knowing any go, I simply tcpdumped the communication between the host and the linstor-controller and saw that after successfully calling /v1/resource-definitions/linstor_demo/resources/ the plugin was calling /v1/resource-definitions/linstor_demo/resources/nodename, that returned 404.
In my case the nodes were called linstore-satellite.nodename.domain.net, including in DNS and in their LinSTOR definitions.
I deleted everything, made all nodenames resolvable from each of them then redefined nodes, storage-pools, resource-groups, volume-groups and it (mostly) worked: it couldn't mount the volume as xfs (from the docs I thought it would be automatically formatted, apparently it's not)
I fomatted the DRBD device (luckily mentioned in the error) with mkfs -t xfs /dev/drbd000x and after that it worked

Docker-volume: I am trying to make a container by using a volume which is already made

I am working on this problem on Windows 10 and using Git-bash.
First, I have made a volume named "myvolume" with the command:
docker volume create myvolume
And I tried to make a Ubuntu container with the command:
docker run -i -t --name newvolume -v myvolume:/root/ ubuntu
However, I get the error message:
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: create myvolume;C: "myvolume;C" includes invalid characters for a
local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'C:/Program Files/Docker/Docker/Resources/bin/docker.exe run --help'.
I guess the problem occurs in Windows 10, and not in the Linux environment,
but I would like to figure out it in Windows.
Anyone know this problem?
Thank you in advance :)

When using docker option --mount the target folder is seen as not absolute, while there is no issue when using -v

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 ...
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
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

Resources