构建镜像:docker build -t 镜像名:$1 .
$1是版本号
镜像打包:docker save -o 镜像保存目录/镜像名.tar 镜像名:1.0.0
启动临时容器(--rm 表示退出后自动删除容器):
- 如果镜像内没有
/bin/sh,可以尝试 bash(如 --entrypoint /bin/bash),或其他 shell(如 ash,适用于 Alpine 基础镜像)。
- 示例:查看
nginx:latest 镜像的文件:
docker run --rm -it --entrypoint /bin/sh nginx:latest