本文介绍基于 Dockerfile 和 docker build
命令构建新的 Docker 镜像。
1 第一个 Dockerfile
让我们创建一个目录并编写一个 Dockerfile 文件吧,这是一个包含简单 Web 服务器的 Docker 镜像。
static_web 是存储 Dockerfile 文件的文件夹,称这个目录为构建上下文(build context),Docker 会在构建竟像时将上下文中的文件和目录上传到 Docker 守护进程。
mkdir static_web
cd static_web
vim Dockerfile
2025/4/1大约 4 分钟