简体   繁体   中英

Docker volume - windows host and linux container

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 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: 在此处输入图像描述 The Mounts seems to consider "Program Files/Git/app" the destination / container folder but it should simply be "/app"

Binds: 在此处输入图像描述

I was running the command with VSCode in a GitBash Terminal

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

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

Running the exact same command with CMD solved my issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM