根据Dockerfile创建hello docker镜像

一、编写hello可执行c文件:

1、安装:gcc glibc glibc-static

yum install -y gcc glibc glibc-static

2、编写hello.c:vim hello.c

#include<stdio.h>

int main()
{
    printf("hello docker
");
}

3、编译

gcc -static hello.c -o hello

二、创建docker镜像:

1、创建Dockerfile,vim Dockerfile:

FROM scratch
ADD hello /
CMD ["/hello"]

 2、创建镜像:

docker build -t zhengchuzhou/hello-world .

 3、测试:

docker run zhengchuzhou/hello-world

原文地址:https://www.cnblogs.com/zhengchuzhou/p/9790948.html