一、用c打造自己的hello-world
- vim 打开main.c
root@ali001:~# mkdir demo1 && cd demo1 && vim main.c
- main.c的代码
#include <stdio.h>
int main(){
printf("hello world!\n");
return 0;
}
- 静态编译
root@ali001:~# gcc -static main.c -o hello
现在你拥有了一个执行程序。
二、创建镜像
- 编写自己的Dockerfile
FROM scratch
ADD hello /
CMD ["/hello"]
- 创建
root@ali001:~# docker build -t johnyucn/hello-world
- 运行:
docker run johnyucn/hello-world
网友评论