【发布时间】:2020-02-28 12:26:53
【问题描述】:
我目前正在研究奇异性和 docker。我正在为 MPI 环境运行奇点。
我想利用 MPI 的奇异性优势,但奇异性文件非常大。所以在运行奇点图像之后,我想 将其转换为 docker 镜像,然后保存,这样可以节省磁盘空间。
这可以将奇异图像转换为 docker 图像吗?
【问题讨论】:
标签: docker containers singularity-container
我目前正在研究奇异性和 docker。我正在为 MPI 环境运行奇点。
我想利用 MPI 的奇异性优势,但奇异性文件非常大。所以在运行奇点图像之后,我想 将其转换为 docker 镜像,然后保存,这样可以节省磁盘空间。
这可以将奇异图像转换为 docker 图像吗?
【问题讨论】:
标签: docker containers singularity-container
使用 Singularity 容器化 MPI 应用程序并不是很困难,但它的代价是对主机系统的额外要求。
这意味着您必须为此自定义图像选择正确的图像库。 this example 之类的东西:
FROM tacc/tacc-ubuntu18-mvapich2.3-psm2:0.0.2
RUN apt-get update && apt-get upgrade -y && apt-get install -y python3-pip
RUN pip3 install mpi4py
COPY pi-mpi.py /code/pi-mpi.py
RUN chmod +x /code/pi-mpi.py
ENV PATH "/code:$PATH"
【讨论】:
一般来说,它是在另一个方向上完成的:基于 Docker 构建一个奇点镜像。如果您打算将其存储为 docker 映像而不是奇异点,那么最好的选择是将其构建为 Docker 并根据需要转换为奇异点。我知道有几个实验室使用这种方法:通过 Dockerfile 构建,推送到 Docker hub 进行存储,直接从 docker hub 镜像构建奇异镜像。
但是,奇点图像通常比 docker 图像小。另一个答案tacc/tacc-ubuntu18-mvapich2.3-psm2:0.0.2 中提到的基础 docker 镜像是 497MB,但奇点镜像只有 160MB。 ubuntu:latest 是 64.2MB 和 25MB,python:latest 是 933MB 和 303MB。
【讨论】:
ubuntu:latest 的压缩大小为 25.9 MB,python 为 341.02 MB。
正如@tsnowlan 在他们的回答中所说,通常工作流程是从 Docker 到 Singularity。但是有一种方法可以从现有的 Singularity 镜像制作 Docker 镜像。这不会利用 Docker 的层缓存功能。
总体思路是:
这里是 bash,在 alpine:latest 上演示:
singularity pull docker://alpine:latest
# Find out which SIF ID to use (look for Squashfs)
singularity sif list alpine_latest.sif
# Get the environment variables defined in the Singularity image.
singularity sif dump 2 alpine_latest.sif
singularity sif dump 3 alpine_latest.sif > data.squash
unsquashfs -dest data data.squash
# See the Dockerfile definition below
docker build --tag alpine:latest .
Dockerfile 的内容:
FROM scratch
COPY data /
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CMD ["/bin/ash"]
有关 Singularity 和 Docker 的更多信息,我建议查看 Singularity's documentation on the topic。
【讨论】: