根据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\n");
}

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

 

posted @ 2018-10-15 14:48  郑楚周  阅读(994)  评论(0编辑  收藏  举报