简体   繁体   中英

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?

I just did it on Linux, but can not find how to do it on windows (docker).

I did on Linux:

FROM scratch

ADD hello /

ENTRYPOINT  ["/hello"]

g++ -o hello -static hello.cc

and it worked.

But how to make it work on windows?

Why it is impossible?

How Microsoft create their base images?

There is no scratch base image for Windows docker containers. Microsoft publishes base images on hub.docker.com that you can use as an alternative. The first line changes the escape character from \ to avoid escaping windows style paths.

# 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:

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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