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
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.
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.
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).
First, save your docker image.
sudo docker save image_id -o local.tar
Then copy to another machine in any way you like
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With