Search code examples
dockersingularity-container

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 ???


Solution

  • 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:latest .
    sudo singularity build my_container.sif docker-daemon://local/my_container:latest
    

    Using docker://my_container looks 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.


    EDIT: Both singularity and apptainer now require an explicit tag name for the source docker container. Answer updated accordingly.