In the multi-phase construction of Dockerfile, how to specify a real mount path?

can docker mount only one directory at run time? Because I use a multi-phase build (see
http://ju.outofmemory.cn/entr.), the dependency needs to be downloaded again for the first phase of each build.

I think we can mount a path on the mother machine to the dependent third-party library in the first phase, and the next build or other project build will be much faster.

can you do that?

Mar.17,2021

roughly speaking, take Node.js, which I am a little familiar with, for example, you may not want to create a dependent package folder called node_modules in the container, but mount a directory of the host, right? But in the process of building, you need to download and rely on it more than once? Or are there multiple dependent package folders?
I haven't tried it, but I guess even if you have more than one installation package folder, the container can be mounted one by one, so it should be possible to do so:

docker run -d -v /dir1:/dir1 -v /dir2:/dir2 image:version

but in theory, this is not very good. After all, the dependency package of the image has too much to do with the running environment. This is how I do Dockerfile:

COPY ./package.json /app
CMD npm install
COPY ./ /app
RUN npm start

I first copy the dependency configuration file into the image, then install the dependency package, and then copy the project.
after this, as long as the dependency package configuration file remains unchanged, the mirror layer in the step of installing the dependency package can be used repeatedly, and the construction speed will be greatly improved.

I hope I can help you.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4504e-4433e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4504e-4433e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?