docker镜像之hello-world

1、如何查看一个镜像(例如hello-world)的dockerfile文件?

dockerfile得到该镜像的docker hub页面去看
https://github.com/docker-library/hello-world/blob/7ecae6978055d2fb6960e2a29d24a2af612e2716/amd64/hello-world/Dockerfile
https://registry.hub.docker.com/_/hello-world(simpletag or sharedtag)

2、如何解析hello-world的dockerfile内容?

1、FROM scratch
此镜像是从白手起家,从 0 开始构建。
2、COPY hello /
将文件“hello”复制到镜像的根目录。
3、CMD ["/hello"]
容器启动时,执行 /hello
镜像 hello-world 中就只有一个可执行文件 “hello”,其功能就是打印出 “Hello from Docker ......” 等信息。

3、什么是base镜像?

镜像能提供一个基本的操作系统环境,用户可以根据需要安装和配置软件。这样的镜像我们称作 base 镜像。

4、这个从scratch作为base构建的hello镜像没有任何环境(包括bash shell),那它是怎么执行/hello的呢?

c语言编写的一个hello world,是个二进制可执行文件,不需要依赖任何第三方库,linux kernel直接就能执行

5、怎么下载一个镜像到本地?

docker pull image-name eg:hello-world、centos、httpd

原文地址:https://www.cnblogs.com/Richardo-M-Q/p/13969316.html