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

2

6

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!

    Jilly answered 20/1, 2021 at 2:5 Comment(1)
    If the provided answer helped in solving your problem, please mark the question as solved by accepting the answer.Flanders
    F
    9

    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
    
    Flanders answered 20/1, 2021 at 5:6 Comment(0)
    C
    0

    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.

    Caine answered 9/2, 2023 at 7:0 Comment(0)

    © 2022 - 2024 — McMap. All rights reserved.