You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
525 B
Bash

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
set -e # 出错即退出
IMAGE_NAME="chunlinwang/myubuntu"
TAG="latest"
CONTAINER_NAME="myubuntu"
TMP_FILE="myubuntu_flat.tar"
echo "[+] 导出容器文件系统..."
docker export "$CONTAINER_NAME" -o "$TMP_FILE"
echo "[+] 重新导入镜像(覆盖 $IMAGE_NAME:$TAG..."
docker import \
-c 'ENTRYPOINT ["/entrypoint.sh"]' \
"$TMP_FILE" "$IMAGE_NAME:$TAG"
echo "[+] 删除临时文件..."
rm -f "$TMP_FILE"
echo "[+] 镜像重打包完成,当前镜像信息:"
docker images | grep "$IMAGE_NAME"