-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to build a singularity image from a local docker image (not a registry image)? #1537
Comments
Hi @bbarker. I'm going to copy and paste the description from @dctrud here.
You're right, this should really be in the Singularity docs. Do you feel like submitting a PR to https://github.com/singularityware/singularityware.github.io/tree/docs/2.5? If not, I can try to get to it when I have a minute. Thanks! |
@GodloveD @psteinb It seems that this approach requires root access on the host. Without being root it (2.4-dist) just says:
Is there another workaround for this step which does not require |
I'm going to ping @dctrud and @vsoch on this. I know you can do something like this without sudo: $ singularity build my_image docker://me/my_image But don't know if you can supply a custom URI (localhost) with that syntax. |
It should work like this...
|
Thanks @dctrud for the advice. Works great for me. |
Just a reference to #2255 that this does not work with 3.0 at the moment. |
Closing since this is now #2255 |
Just a note to anyone else trying to do this, you can get this to work by specifying Using OPs command: It would be nice if it could be mentioned in the Overview list of targets in https://sylabs.io/guides/3.5/user-guide/build_a_container.html |
The original question here was on a 2.x version of Singularity - for the benefit of anyone using 2.6 still, @dahlo - yes we could add docker-daemon to the page you link. There are other (less commonly usd) sources not mentioned in that quick list. docker-archive and oci archives are supported too. |
@GodloveD and everyone, I'm using singularity 2.6.0-dist, without root permissions (I don't have docker installed). How can I run a local docker image? Running: What can I do? |
@efratushava - In 2.x you have to build the docker image with docker somewhere, push it to a registry (either DockerHub, something else, or a local registry), than have Singularity pull from that registry, per the comment above. It is not possible to just build or run from If you need to keep things local, you will need to run a local docker registry somewhere you do have docker, per the comment above: |
@dahlo while this works, I have to be root for it to work. If I run as regular user I get:
This is singularity version 3.5.2 |
@durai23 It looks like your user is not a member of the docker group. If you add it as a member you should be able to do it without sudo. Cheers |
Hello, I was able to successfully take the Docker Image and convert it to singularity .sif image. Using this command Also, when I run this container on docker with this command |
Singularity does not have any concept of $ singularity exec deephyperx.sif /workspace/DeepHyperX/start.sh Also, if you need ports you probably want to check out instances, and you'd need to take a similar approach - a %startscript won't be populated by a Docker conversion, so you'd need to start it and then exec that command to start the service. You can also check out singularity-compose if you want a simpler interaction. |
I would guess you are trying to do something with a port but you haven't created an instance that has permission to. You basically want to duplicate that exec command, but with a singularity instance. |
Hello @vsoch , |
Yes, you likely want to edit that startscript to have the start command, unless you are okay using exec. If you are having trouble I can probably help you test it out over the weekend with singularity-compose: https://singularityhub.github.io/singularity-compose/#/. which will just provide an easy wrapper to doing all this. But you'd have to be willing to share your container recipe to some extent. if not, check out some of the examples https://github.com/singularityhub/singularity-compose-examples. |
@vsoch No problem, I can meet with you over the weekend. In the meantime, I will take a look at the singularity-compose. Thank you. |
Hello, @vsoch |
Hello @vsoch Is it possible we can talk or meet? When you are available? Thank you in advance. |
If you’d like to share your recipe I can reproduce I can offer to help when I have some time, but I’m not able to offer time to meet or talk with you personally. |
Do you mean the docker container? |
Yes or the recipe (Dockerfile). I just need to be able to reproduce your error. |
I used this Docker container to build it locally. |
here you go, see the README for instructions. https://github.com/singularityhub/singularity-compose-examples/tree/master/v2.0/deephyperx. If you use --debug you can see the command that is generated for the instance, in case you don't want to use singularity-compose (or otherwise want to modify it). Singularity compose docs are here if you need singularityhub.github.io/singularity-compose/. Enjoy! |
Do you know if it is possible to do it without singularity-compose? |
sure, just turn on debug for singularity compose and copy paste all the long hairy commands, run those! |
Sorry, what commands do you mean. The reason we are not able to use singularity-compose at the moment is because our HPC does not have sudo privileges enabled and for me to get singularity-compose on it I need sudo privileges. |
Then use your local machine? |
Only if I could. Our research is based on HPC and I have emailed them about it but I am not sure if they will give us sudo privileges or install it for us. |
Is it possible we can meet? I can show you the error I am having. Or I can explain it here if it okay with you? |
I would suggest first going to the hpcng or Sylabs Slack and asking for help there - there are developers there paid to assist with this kind of thing. I've already taken a few hours to put together that example and tell you how to get the commands you seek, and I've just about reached my threshold for providing this kind of help. But I assure you that the Singularity developers can assist you further. |
@vsoch No problem, thank you so much for your help! |
Checking in here, following up on @dtrudg's comment, you don't need to stand up a local Docker registry. If you have the tarball of an image (a la apptainer build new-image.sif docker-archive:file.tar
apptainer run new-image.sif Tested with |
I have often needed to build a Apptainer container from a local Docker image (not from a remote image in a Docker registry). I think that this might be a relatively popular use-case, but currently this workaround is only described in an issue on GitHub (apptainer/singularity#1537 (comment)). It would be nice to also have it in the official docs.
It is documented here -> https://docs.sylabs.io/guides/3.0/user-guide/singularity_and_docker.html#singularity-and-docker Specifically in sections:
|
Version of Singularity:
2.5.1
Expected behavior
Documented way to create a singularity image from a local docker image (not an image on a registry)
Looked at documentation here.
Actual behavior
Steps to reproduce behavior
See above
The text was updated successfully, but these errors were encountered: