sudo gpasswd -a vagrant docker 重启docker 进程 sudo service docker restart docker pull hello-world 这hello-world也是个base image ,很小 运行这个容器 docker run hello-world mkdir hello-world cd hello-world vim hello.c

#include<stdio.h>

int main() { printf("hello docker\n"); } 编译c程序要先安装 yum install gcc yum install glibc-static gcc -static hello.c -o hello ./hello vim Dockerfile FROM scratch ADD hello / CMD ["/hello"] docker build -t skinglzw/hello-world . 构建bese image 完成 docker image ls ls -lh docker history 3c082eba7935

docker run skinglzw/hello-world 这个base image 变成容器,运行这个容器