如何从 dockerfile 构建奇异容器

ale*_*lex 13 docker singularity-container

我想从 dockerfile 构建奇点容器。

我已经从 docker hub 中提取并运行了 docker 镜像。

singularity pull docker://ubuntu:latest
Run Code Online (Sandbox Code Playgroud)

我还从奇点配方文件构建了图像。

singularity build  cpp.sif singularity_file
Run Code Online (Sandbox Code Playgroud)

但我想从 dockerfile 构建奇异图像。

任何人都知道该怎么做。是否可以 ???

Ser*_*rge 22

您可以使用 Singularity Python 将 Dockerfile 转换为奇点配方(反之亦然)。Singularity Python 提供了一些非常有用的实用程序,如果您计划经常使用奇异性,请考虑安装它

pip3 install spython # if you do not have spython install it from the command line

# print in the console
spython recipe Dockerfile

# save in the *.def file
spython recipe Dockerfile > Singularity.def
Run Code Online (Sandbox Code Playgroud)

如果您在使用 pip 时遇到问题,可以下载 spython 或拉取容器,如Singularity Python install中所述。在此处查找有关配方转换的更多信息

  • 我建议使用“>”而不是“&>”,因为“&>”也会将警告写入输出文件,当您尝试使用它时,这当然会导致解析错误。 (2认同)

tsn*_*lan 14

您不能直接从 Dockerfile构建奇点容器,但可以分两步完成。

docker build -t local/my_container .
sudo singularity build my_container.sif docker-daemon://local/my_container
Run Code Online (Sandbox Code Playgroud)

docker://my_container在 Docker Hub 上使用查找容器。当您使用 时docker-daemon,它会查看您本地构建的 docker 容器。您还可以Bootstrap: docker-daemon在 Singularity 定义文件中使用。