Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting docker tar file into a singularity image?

Tags:

I am new to both Docker and Singularity. I recently created the canonical main.c.

#include <stdio.h>
#include <stdlib.h>

int main(void){
    printf("Hello Docker World!\n");
    return 0;
}

I statically compiled this code, i.e.

gcc -static -static-libgcc -static-libstdc++ -o hello main.c

I then built the docker image and could run it, i.e.

dockerd &  ## Start Docker daemon
docker build --tag hello .
docker run hello   ## Outputs "Hello Docker World"

I then save the image so that I can export it to a second computer (which does not have docker, but does have singularity), i.e.

docker save hello > hello.tar

Now on the second machine, which does not have docker but does have singularity, I want to create a singularity image. Tthe singularity documentation give instructions on creating a singularity image from a docker image on Docker Hub, but they do not give instructions on converting from a docker tar'd file.

Question : How would I create a singularity image from my hello.tar

like image 839
irritable_phd_syndrome Avatar asked Oct 10 '18 11:10

irritable_phd_syndrome


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

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. For this reason Docker is not available on the Princeton HPC clusters (neither is nvidia-docker).


1 Answers

  1. First, save your docker image.

    sudo docker save image_id -o local.tar

  2. Then copy to another machine in any way you like

  3. Finally, build a singularity image from the local.tar by

    singularity build local_tar.sif docker-archive://local.tar

    which used the docker-archive bootstrap agent. Can read it here

like image 84
Ruolin Liu Avatar answered Oct 11 '22 18:10

Ruolin Liu