[英]How to create a Dockerfile from scratch for Windows EXE file, which does not have any dependencies?
How to create a Dockerfile from scratch for Windows EXE file, which does not have any dependencies?如何为没有任何依赖关系的 Windows EXE 文件从头开始创建 Dockerfile?
I just did it on Linux, but can not find how to do it on windows (docker).我刚刚在 Linux 上做了,但在 windows(码头工人)上找不到如何做。
I did on Linux:我在 Linux 上做过:
FROM scratch
ADD hello /
ENTRYPOINT ["/hello"]
g++ -o hello -static hello.cc
and it worked.它奏效了。
But how to make it work on windows?但是如何让它在 windows 上工作呢?
Why it is impossible?为什么这是不可能的?
How Microsoft create their base images?微软如何创建他们的基础镜像?
There is no scratch base image for Windows docker containers. Windows docker 容器没有临时基础映像。 Microsoft publishes base images on hub.docker.com that you can use as an alternative.
Microsoft 在 hub.docker.com 上发布基础映像,您可以将其用作替代方案。 The first line changes the escape character from
\
to avoid escaping windows style paths.第一行将转义字符从
\
更改为避免 escaping windows 样式路径。
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2019
ADD hello.exe C:\hello.exe
ENTRYPOINT ["C:\hello.exe"]
I think I found an answer how Microsoft creates base images:我想我找到了 Microsoft 如何创建基础映像的答案:
docker import creates one image from one tarball which is not even an image (just a filesystem you want to import as an image)
Like this:像这样:
tar --numeric-owner --exclude=/proc --exclude=/sys -cvf centos6-base.tar /
cat centos6-base.tar | docker import - centos6-base
docker run -i -t centos6-base cat /etc/redhat-release
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.