Docker Community Forums

Share and learn in the Docker community.

Invalid mount path: mount path must be absolute error (solved)


(Brightbeard) #1

Hi, all,

I’m new to Docker and I have encountered my first error that I can’t seem to overcome or troubleshoot through. I need to use a Bind mount to mount a file I’m working with inside a container, but every rendition of my file path I try results in the following error:

docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: 'C:\QIIME2\Indiana\Run2' mount path must be absolute. See 'docker run --help'.

This is the command I’m running:

docker run --rm -t -i --mount type=bind,source=C:\QIIME2\Indiana\Run2,target=C:\QIIME2\Indiana\Run2 bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

Approaching the issue using a Volume in place of a Bind results in a similar error:

docker run --rm -t -i -v C:\QIIME2\Indiana\Run2 bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt     

docker: Error response from daemon: invalid volume spec "C:\\QIIME2\\Indiana\\Run2": invalid volume specification: 'C:\QIIME2\Indiana\Run2': invalid mount config for type "volume": invalid mount path: '\QIIME2\Indiana\Run2' mount path must be absolute. See 'docker run --help'.

I was led to this approach from a tutorial I’m working through for a different container (where I don’t have this issue) that has me define my Volume as C:\QIIME2\Indiana\Run2:/data. When I include the “:/data” bit at the end of the above command, Docker executes the command and runs the container script, which then fails to locate my file:

docker run --rm -t -i -v C:\QIIME2\Indiana\Run2:/data bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

Error in No filepaths match pattern/name 'IndFun_S1_L001_R1_001.fastq'. All patterns must be matched at least once.

I’m not entirely sure what “:/data” does, so that is part of my problem. When I include that end to my file path when using a Bind instead of a Volume, I still get the same error:

docker run --rm -t -i --mount source=C:\QIIME2\Indiana\Run2:/data,target=C:\QIIME2\Indiana\Run2:/data bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt 
docker: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:\QIIME2\Indiana\Run2:/data' mount path must be absolute. See 'docker run --help'.

For reference, here is the command from the other container tutorial that executes perfectly with no file path errors and takes the files located in the folder and generates new files in the same folder on my C: drive:

docker run --rm -t -i -v C:\QIIME2\Tutorials\qiime2-importing-tutorial:/data qiime2/core:2017.9 qiime tools import --type EMPSingleEndSequences --input-path emp-single-end-sequences --output-path emp-single-end-sequences.qza

I’ve spent three days trying to wrap my head around this issue and I’m at a complete loss. Any help with this would be greatly appreciated. Again, I’m pretty new to all of this so any information, such as why that :/data changes my error message or how to execute this properly, is welcome.


(Sam) #2

and the source path exists, right?

some other examples show removing the : and changing the \ to /

-v //c/QIIME2/Indiana/Run2:/data

it seems the parser is confused by the C:
invalid mount path: '\QIIME2\Indiana\Run2

(Brightbeard) #3

The source path does exist. Running -v //c/QIIME2/Indiana/Run2:/data gave me the same error as -v C:\QIIME2\Indiana\Run2:/data:

Error in No filepaths match pattern/name 'IndFun_S1_L001_R1_001.fastq'. All patterns must be matched at least once.

And sticking it into my Bind Mount command yields another error:

docker run --rm -t -i --mount type=bind,source=//c/QIIME2/Indiana/Run2:/data,target=//c/QIIME2/Indiana/Run2:/data bwawrik/qiime -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist.

(Sam) #4

that is the -i parm, not the -v parm
-i IndFun_S1_L001_R1_001.fastq

note that the docker runtime is NOT in ‘this’ (the current directory) folder…

(Sam) #5

also, please show the output of dir C:\QIIME2\Indiana\Run2 on the host

(Brightbeard) #6


I think that issue is stemming from my working folder not mounting to the container. The IndFun_S1_L001_R1_001.fastq file is contained within C:\QIIME2\Indiana\Run2 and no matter how I code it (e.g C:\QIIME2\Indiana\Run2\IndFun_S1_L001_R1_001.fastq; %cd%IndFun_S1_L001_R1_001.fastq, etc.), I run into that error. I was under the impression that despite the container script being in Python, my Windows path should be fine since it was mounted to the container.

Here’s the output you requested:

C:\QIIME2\Indiana\Run2>dir C:\QIIME2\Indiana\Run2
 Volume in drive C is Windows
 Volume Serial Number is D661-BCB2

 Directory of C:\QIIME2\Indiana\Run2

11/13/2017  05:06 PM    <DIR>          .
11/13/2017  05:06 PM    <DIR>          ..
10/18/2017  08:13 AM     2,297,782,630 IndFun_S1_L001_R1_001.fastq
10/17/2017  08:58 PM     2,309,980,676 IndFun_S1_L001_R2_001.fastq
11/16/2017  04:06 PM               890 QIIME2 Indiana Code.txt
11/13/2017  10:32 AM             9,130 Run 2 metadata.xlsx
               4 File(s)  4,607,773,326 bytes
              2 Dir(s)  110,330,286,080 bytes free

(Sam) #7

ok, on the first error…

there are a bunch of parms, -v -rm -t
then the name of the image bwawrik/qiime
then the command (and its parms to pass to the container) -i IndFun_S1_L001_R1_001.fastq -o seq_counts.txt

that happens INSIDE the container…
so the path inside would be /data/IndFun_S1_L001_R1_001.fastq
and the runtime is sitting at the root NOT the volume location…

i see u mentioned not knowing what /data meant

the -v is source_path (host):container_path (inside container)

net, you have to tell docker, where in the containers file system the host volume should be located (mounted in linux terms)

(Brightbeard) #8

Ah! I think I understand now. Essentially, I need to write my mounting as: -v source_path (In Windows terms):container_path (In Linux terms) and then the python script should be able to locate the file I’m specifying? i.e. tell Docker to mount this path like that inside the container? I’ll give that a shot.

Do you have any idea why the --mount command doesn’t think my file path is absolute when I use type=bind? This will probably become a non-issue if I get the volume mounting to work like we just discussed, but it will still nag at me…

Also, thanks so much for your help. I’ve really learned a lot from all this!

(Sam) #9

well, one would expect that if the container is running Windows, then the container_path should be in windows terms.
I ’ think’ the base drive is C: and /data would be C:/data by default…

for debugging I think if you remove your python script and its parms and use cmd instead, then u will get a command prompt from the container where you can use DIR to look around…and test your script…

(Sam) #10

just catching up on docker from a couple years ago and haven’t seen the --mount/bind approach… so not really sure what its does

(Sam) #11

well, the syntax for bind is a verbose kind of -v

–mount type= , source=, target=

as such the source and target paths must be real paths…

you specified

that makes the source path not valid… (because u didn’t know at the time what the :/data meant on -v)…

so your bind should have been (to match the -v version)

–mount type=bind,source=//c/QIIME2/Indiana/Run2,target=/data
and source=c:\QIIME2\Indiana\Run2
might work as well. (note the ‘:’ is used as a source/target separator in -v syntax, so its hard for the parser to figure out what u mean)

(Brightbeard) #12

Okay, thanks to your help I’ve finally gotten it to work! The source/target separator was throwing the whole script off. Additionally, all my file paths needed to be hard-coded in to both find the file and create files in the specified folder. Here’s the working code for both the Volume and Bind mount approach with my specific file paths included:

docker run --rm -t -i -v %cd%://c/QIIME2/Indiana/Run2 bwawrik/qiime -i //c/QIIME2/Indiana/Run2/IndFun_S1_L001_R1_001.fastq -o //c/QIIME2/Indiana/Run2/seq_counts.txt

docker run --rm -t -i --mount type=bind,source=//c/QIIME2/Indiana/Run2,target=//c/QIIME2/Indiana/Run2 bwawrik/qiime -i //c/QIIME2/Indiana/Run2/IndFun_S1_L001_R1_001.fastq -o //c/QIIME2/Indiana/Run2/seq_counts.txt

Now, docker successfully mounts my folder inside the container, executes the python script with my file, generates the output file of interest in the folder, and then closes the container.

Again, thank you so much for all the help. Hopefully this thread is useful for others who are struggling with this specific syntax for attaching folders to containers properly.

(Sam) #13

you probably could have used %cd% in the source of the bind type as well as those should not be sensitive to the : in the normal windows paths.

thanks for showing both approaches, -v and -mount type=bind