美文网首页
打造自己的hello-world docker镜像

打造自己的hello-world docker镜像

作者: JohnYuCN | 来源:发表于2020-02-24 08:03 被阅读0次

一、用c打造自己的hello-world

  1. vim 打开main.c
root@ali001:~# mkdir demo1 && cd demo1 && vim main.c
  1. main.c的代码
#include <stdio.h>

int main(){
        printf("hello world!\n");
        return 0;
}
  1. 静态编译
root@ali001:~#  gcc -static main.c -o hello

现在你拥有了一个执行程序。

二、创建镜像

  1. 编写自己的Dockerfile
FROM scratch
ADD hello /
CMD ["/hello"]           
  1. 创建
root@ali001:~#  docker build -t johnyucn/hello-world
  1. 运行:
docker run johnyucn/hello-world

相关文章

网友评论

      本文标题:打造自己的hello-world docker镜像

      本文链接:https://www.haomeiwen.com/subject/muwpqhtx.html