目录
1.原镜像大小
1.1 Dockerfile文件
1.2 hello文件
1.3 进入文件夹myprojecthello打包镜像
1.4查看打包的镜像
2.通过拆分文件夹减少镜像大小
2.1 创建两个文件夹
2.2 移动文件
2.3 打包镜像
3. 通过 .dockerignore 文件的方式
3.1 创建 world.txt文件
3.2 创建 .dockerignore 文件
3.3 打包镜像
4. 查看打包的所有镜像
FROM busybox
COPY /hello /
RUN cat /hello
hello world !!!

最后的 . 代表的是要打包镜像的上下文, 该文件内的所有内容都会打包到镜像里面
docker build -t helloapp:v1 .
镜像打包的结果为 3.072KB

mkdir -p dockerfiles context
mv Dockerfile dockerfiles
mv hello context
docker build --no-cache -t helloapp:v2 -f dockerfiles/Dockerfile context

echo 'world' > context/world.txt
touch context/.dockerignore

docker build --no-cache -t helloapp:v3 -f dockerfiles/Dockerfile context

可以看到 .dockerignore 文件内,忽略的文件没有被打到镜像中
docker images | grep hello