0

I am using docker toolbox on windows home and having trouble figuring out how to get bind mount working in my frontend app. I want changes to be reflected upon changing content in the src directory.

App structure:

enter image description here

Dockerfile:

FROM node
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]

Docker commands:

  1. (within the frontend dir) docker build -t frontend .
  2. docker run -p 3000:3000 -d -it --rm --name frontend-app -v ${cwd}:/app/src frontend

Any help is highly appreciated.

EDIT

cwd -> E:\docker\multi\frontend

cwd/src is also not working. However, i find that with /e/docker/multi/frontend/src the changes are reflected upon re running the same image

  • What is the value of `cwd`? – Ryan Schaefer Jul 16 '21 at 13:57
  • cwd -> E:\docker\multi\frontend. I believe i need to add src to that but i tried it out with ${cwd/src} but that is not running the bind mount. – Shiladitya Thakur Jul 16 '21 at 14:19
  • If you wanted to use cwd it would be `${cwd}/src:..` but it sounds like you have it working now anyways. – im_baby Jul 16 '21 at 14:22
  • I tried ${cwd}/src:.. at first but that was crashing the app on start. However, ${cwd/src}:.. is working without crashing. Although bind mount is not working on that still. Using the whole absolute path works apparently. – Shiladitya Thakur Jul 16 '21 at 14:30

1 Answers1

0

i have ran into same issue it feels like we should use nodemon to look for file changes and restart the app. because with docker reference and tutorials project does the thing.

  • As mentioned by Mr Shailaditya Thakur, using the abs path works with bind mounts. – user19025283 May 03 '22 at 15:22
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '22 at 05:42
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31683525) – Ethan May 07 '22 at 22:20