Home > Back-end >  Docker volume - windows host and linux container
Docker volume - windows host and linux container

Time:12-31

I have this very simple Dockerfile :

FROM node:current-alpine3.14 AS baseImage
WORKDIR /app
COPY package* .
RUN npm install
COPY . .
CMD ["npm", "run", "watch"]

Then I run : docker build . -t myImage

And then docker run -p 8080:3000 -v /c/myFolder:/app myImage

So basically I want a "shared" between the app folder in the container and the C:\myFolder on my host.

But it doesn't work : For instance, if I update C:\myFolder\index.js, the changes doesnt occur in the container.

And here is what docker inspect myContainer returns under the Mounts section. Is it something to do with escaping / path format? Or am I missing something fundamental in working with volume ? or WORKDIR ?

Mounts : enter image description here The Mounts seems to consider "Program Files/Git/app" the destination / container folder but it should simply be "/app"

Binds: enter image description here

CodePudding user response:

the command

docker run -p 8080:3000 -v /c/myFolder:/app myImage was run with gitbash for windows

Running the exact same command with CMD solved my issue.

it looks like GitBash was converting the /app destination folder into \Program Files\Git\app

  • Related