简体   繁体   English

复制时Dockerfile的奇怪行为

[英]Dockerfile weird behaviour when copying

I am building a dockerfile from a SPA using very basic js and html我正在使用非常基本的 js 和 html 从 SPA 构建 dockerfile

I want to copy only some files to the docker image, but I am really struggling to do so as following: docker file commands我只想将一些文件复制到 docker 镜像,但我真的很努力这样做: docker file commands

I have also tried several variations, ie removing ./ from the index html, also doing it on one line using "array" style... But all these tries end up in writing the index.html content to all files, for example I will see the index html content inside the style.css,seeing it from the dev Tools on chrome.我还尝试了几种变体,即从索引 html 中删除 ./,也使用“array”样式在一行上执行...但所有这些尝试最终都将 index.html 内容写入所有文件,例如我将在 style.css 中看到索引 html 内容,从 chrome 上的开发工具中看到它。 Therefore the page won't work as expected因此页面将无法按预期工作

The only workaround I have managed to get working is making a script using copy and placing everything on a "dist" folder, then copying everything on the folder to the docker image.我设法开始工作的唯一解决方法是使用 copy 制作脚本并将所有内容放在“dist”文件夹中,然后将文件夹中的所有内容复制到 docker 映像。 That way it would work, but I'd prefer not to use a script and instead copy everything needed from the dockerfile straight away.这样它就可以工作,但我不想使用脚本,而是直接从 dockerfile 复制所需的所有内容。

Any help is appreciated任何帮助表示赞赏

Okay, after more than 5h trying workarounds, I found out the question myself.好的,在尝试解决方法超过 5 小时后,我自己发现了这个问题。 Problem was not understanding COPY command, I was copying files to the root, instead of placing them on the correct folder: Correct Dockerfile问题是不理解COPY命令,我将文件复制到根,而不是将它们放置在正确的文件夹:正确Dockerfile

Notice the folder where every file is copied to请注意将每个文件复制到的文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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