{"id":217894,"date":"2017-06-08T23:45:19","date_gmt":"2017-06-09T03:45:19","guid":{"rendered":"http:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/uncategorized\/singularity-and-docker-singularity.php"},"modified":"2017-06-08T23:45:19","modified_gmt":"2017-06-09T03:45:19","slug":"singularity-and-docker-singularity","status":"publish","type":"post","link":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/singularity\/singularity-and-docker-singularity.php","title":{"rendered":"Singularity and Docker | Singularity"},"content":{"rendered":"<p><p>    Singularity is good friends with Docker. The reason is because    the developers use and really like using Docker, and scientists    have already put much resources into creating Docker images.    Thus, one of our early goals was to support Docker. What can    you do?  <\/p>\n<p>    You can shell, import, run, and exec.  <\/p>\n<p>    The core of a Docker image is basically a compressed set of    files, a set of .tar.gz    that (if you look in your Docker image folder on your host machine,    you will see. The Docker Registry, which you probably interact    with via Docker Hub, serves these layers. These are the    layers that you see downloading when you interact with the    docker daemon. We are going to use these same layers for    Singularity!  <\/p>\n<p>    The Docker engine communicates with the Docker Hub via the    Docker Remote API, and guess what, we can    too! The easiest thing to do is create an image, and then pipe    a Docker image directly into it from the Docker Registry. You    dont need Docker installed on your machine, but you will need    a working internet connection. Lets create an ubuntu operating    system, from Docker:  <\/p>\n<p>    Note that the default size is 768MB, you can modify this by    adding the --size or    -s argument like:  <\/p>\n<p>    If you arent sure about the size? Try building into a folder first.  <\/p>\n<p>    Next, lets import a Docker image into it!  <\/p>\n<p>    Just like Docker has the Dockerfile, Singularity has a file    called Singularity that (currently) applications like    Singularity Hub know to sniff for. For reproducibility of your    containers, our strong recommendation is that you build from    these files. Any command that you issue to change a container    with --writable is by    default not recorded, and your container loses its    reproducibility. So lets talk about how to make these files!    First, lets look at the absolute minimum requirement:  <\/p>\n<p>    We would save this content to a file called Singularity and then issue the    following commands to bootstrap the image from the file  <\/p>\n<p>    but just those two lines and doing bootstrap is silly, because    we would achieve the same thing by doing:  <\/p>\n<p>    The power of bootstrap comes with the other stuff that you can    do! This means running specific install commands, specifying    your containers runscript (what it does when you execute it),    adding files, labels, and customizing the environment. Here is    a full Singularity file:  <\/p>\n<p>    In the example above, I am overriding any Dockerfile    ENTRYPOINT or    CMD because I have    defined a %runscript. If    I want the Dockerfile ENTRYPOINT to take preference, I    would remove the %runscript section. If I want to use    CMD instead of    ENTRYPOINT, I would    again remove the runscript, and add IncludeCmd to the header:  <\/p>\n<p>    Did you know that you can commit this Singularity file to a    Github repo and it will automatically build for you when you    push to Singularity Hub?. This will ensure maximum    reproducibility of your work.  <\/p>\n<p>    Docker has two commands in the Dockerfile that have something to do    with execution, CMD and    ENTRYPOINT. The    differences are subtle, but the best description Ive found is    the following:  <\/p>\n<p>        A CMD is to provide        defaults for an executing container.      <\/p>\n<p>    and  <\/p>\n<p>        An ENTRYPOINT helps        you to configure a container that you can run as an        executable.      <\/p>\n<p>    Given the definition, the ENTRYPOINT is most appropriate for    the Singularity %runscript, and so using the default    bootstrap (whether from a docker:\/\/ endpoint or a Singularity spec file) will set the    ENTRYPOINT variable as    the runscript. You can change this behavior by specifying    IncludeCmd: yes in the    Spec file (see below). If you provide any sort of %runscript in your Spec file, this    overrides anything provided in Docker. In summary, the order of    operations is as follows:  <\/p>\n<p>    In the example above, you probably saw that we referened the    docker image first with the uri docker:\/\/ and that is important to    tell Singularity that it will be pulling Docker layers. To ask    for ubuntu, we asked for docker:\/\/ubuntu. This uri that we    give to Singularity is going to be very important to choose the    following Docker metadata items:  <\/p>\n<p>    When we put those things together, it looks like this:  <\/p>\n<p>    By default, the minimum requirement is that you specify a    repository name (eg, ubuntu) and it will default to the    following:  <\/p>\n<p>    If you provide a version instead of a tag, that will be used    instead:  <\/p>\n<p>    You can have one or the other, both are considered a digest    in Docker speak.  <\/p>\n<p>    If you want to change any of those fields, then just specify    what you want in the URI.  <\/p>\n<p>    For both import and bootstrap using a build spec file, by    default we use the Docker Registry index.docker.io. Singularity first    tries the call without a token, and then asks for one with pull    permissions if the request is defined. However, it may be the    case that you want to provide a custom token for a private    registry. You have two options. You can either provide a    Username and    Password in the build    specification file (if stored locally and there is no need to    share), or (in the case of doing an import or needing to secure    the credentials) you can export these variables to    environmental variables. We provide instructions for each of    these cases:  <\/p>\n<p>    You can simply specify your additional authentication    parameters in the header with the labels Username and Password:  <\/p>\n<p>    Again, this can be in addition to specification of a custom    registry with the Registry parameter.  <\/p>\n<p>    You can export your username, and password for Singularity as    follows:  <\/p>\n<p>    If you are having trouble, you can test your token by obtaining    it on the command line and putting it into an environmental    variable, CREDENTIAL:  <\/p>\n<p>    This should place the token in the environmental variable    TOKEN. To test that your    token is valid, you can do the following  <\/p>\n<p>    The above call should return the tags list as expected. And of    course you should change the repo name to be one that actually    exists that you have credentials for.  <\/p>\n<p>    Why wont my image bootstrap work? If you cant find an answer    on this site, please ping us an issue. If youve found an answer    and youd like to see it on the site for others to benefit    from, then post to us here.  <\/p>\n<p>    This entire process will hopefully change in two ways. First,    we hope to collapse the image creation and bootstrapping, so    you have the option to do them both in one full swing. Second,    we hope to eventually figure out some kind of solution to    import Docker containers without needing sudo.  <\/p>\n<p><!-- Auto Generated --><\/p>\n<p>Continue reading here:<\/p>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"http:\/\/singularity.lbl.gov\/docs-docker\" title=\"Singularity and Docker | Singularity\">Singularity and Docker | Singularity<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> Singularity is good friends with Docker. The reason is because the developers use and really like using Docker, and scientists have already put much resources into creating Docker images. Thus, one of our early goals was to support Docker.  <a href=\"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/singularity\/singularity-and-docker-singularity.php\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"limit_modified_date":"","last_modified_date":"","_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[431648],"tags":[],"class_list":["post-217894","post","type-post","status-publish","format-standard","hentry","category-singularity"],"modified_by":null,"_links":{"self":[{"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/posts\/217894"}],"collection":[{"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/comments?post=217894"}],"version-history":[{"count":0,"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/posts\/217894\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/media?parent=217894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/categories?post=217894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.euvolution.com\/futurist-transhuman-news-blog\/wp-json\/wp\/v2\/tags?post=217894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}