1、scratch构建一个基础镜像
Scratch是一个空的Docker镜像。
编写C程序 hello.c:
#include <stdio.h>
int main()
{
printf("hello docker\n");
}
编译成一个二进制文件:
$ gcc --static -o hello hello.c
$ ./hello
hello docker
$
编写Dockerfile:
FROM scratch
ADD hello /
CMD ["/hello"]
构建:
$ docker build -t hello .
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello latest 2936e77a9daa 40 minutes ago 872kB
运行:
$ docker container run -it hello
hello docker
2、创建自己的centos
原始的centos没有vim和ifconfig:
[root&