一、编写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"]

根据Dockerfile创建hello   docker镜像

 2、创建镜像:

docker build -t zhengchuzhou/hello-world .

根据Dockerfile创建hello   docker镜像

 3、测试:

docker run zhengchuzhou/hello-world

根据Dockerfile创建hello   docker镜像

 

相关文章:

  • 2021-10-04
  • 2021-11-06
  • 2021-10-22
  • 2022-12-23
  • 2021-11-06
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-17
  • 2021-05-19
  • 2021-11-06
  • 2021-06-04
  • 2021-05-27
相关资源
相似解决方案