Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to build singularity container from dockerfile

I want to build singularity container from dockerfile.

I have pulled and run docker images from docker hub with singularity.

singularity pull docker://ubuntu:latest

I have also build the image from singularity recipe file.

singularity build  cpp.sif singularity_file

But I want to build singularity image from dockerfile.

Anyone know how to do it. Is it possible ???

like image 971
alex Avatar asked Feb 20 '20 07:02

alex


People also ask

How do you make a Singularity container?

To build a singularity container, you must use the build command. The build command installs an OS, sets up your container's environment and installs the apps you need. To use the build command, we need a definition file.

Can Singularity run Docker containers?

Singularity can also start containers directly from Docker images, opening up access to a huge number of existing container images available on Docker Hub and other registries.

Is Singularity better than Docker?

Singularity is a Secure Alternative to Docker Docker images are not secure because they provide a means to gain root access to the system they are running on.


2 Answers

You cannot build a singularity container directly from a Dockerfile, but you can do it in a two-step process.

docker build -t local/my_container .
sudo singularity build my_container.sif docker-daemon://local/my_container

Using docker://my_container look for the container on Docker Hub. When you use docker-daemon, it looks at your locally built docker containers. You can also use Bootstrap: docker-daemon in a Singularity definition file.

like image 96
tsnowlan Avatar answered Oct 24 '22 11:10

tsnowlan


You can transform a Dockerfile into a singularity recipe or vise-versa using Singularity Python. Singularity Python offers some very helpful utilities, consider to install it if you plan to work with singularity a lot

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

If you have problems with pip you can download spython or pull a container as described in Singularity Python install. Find more about recipe conversion here

like image 45
Serge Avatar answered Oct 24 '22 11:10

Serge