Docker在当前目录中添加每个文件 [英] Docker Add every file in current directory
问题描述
我有一个简单的Web应用程序,希望将其放置在Docker容器中。角度应用程序位于 frontend /
文件夹中,该文件夹与 application /
文件夹一起。
I have a simple web application that I would like to place in a docker container. The angular application exists in the frontend/
folder, which is withing the application/
folder.
当Dockerfile位于 application /
文件夹中时,内容如下:
When the Dockerfile is in the application/
folder and reads as follows:
FROM node
ADD frontend/ frontend/
RUN (cd frontend/; npm install;)
CMD (cd frontend/; npm start;)
一切正常。
但是,当我将Dockerfile移到 frontend /
文件夹并将其更改为
However, when I move the Dockerfile into the frontend/
folder and change it to read
FROM node
ADD . frontend/
RUN (cd frontend/; npm install;)
CMD (cd frontend/; npm start;)
没有文件被复制并且项目无法运行。
no files are copied and the project does not run.
如何将当前目录中的每个文件和文件夹递归添加到我的文件中
How can I add every file and folder recursively in the current directory to my docker image?
推荐答案
最终工作的Dockerfile是
The Dockerfile that ended up working was
FROM node
ADD . / frontend/
RUN (cd frontend/; npm install;)
CMD (cd frontend/; npm start;)
向@Matt喊叫,以使领先。 / ./
,但是我认为唯一不起作用的原因是由于某种原因,我的应用程序仅在目录内而不是在 root目录中时才运行。这可能与@VonC观察到的节点图像没有WORKDIR有关。
Shoutout to @Matt for the lead on . / ./
, but I think the only reason that didn't work was because for some reason my application will only run when it is inside a directory, not in the 'root'. This might have something to do with @VonC's observation that the node image doesn't have a WORKDIR.
这篇关于Docker在当前目录中添加每个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!