Scratch是一个空的Docker镜像。
    通过scratch来构建一个基础镜像。

    hello.c

    1. #include <stdio.h>
    2. int main()
    3. {
    4. printf("hello docker\n");
    5. }

    编译成一个二进制文件

    1. $ gcc --static -o hello hello.c
    2. $ ./hello
    3. hello docker
    4. $

    Dockerfile

    1. FROM scratch
    2. ADD hello /
    3. CMD ["/hello"]

    构建

    1. $ docker build -t hello .
    2. $ docker image ls
    3. REPOSITORY TAG IMAGE ID CREATED SIZE
    4. hello latest 2936e77a9daa 40 minutes ago 872kB

    运行

    1. $ docker container run -it hello
    2. hello docker