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. We are going to use this local repository for this first set of methods.
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. This first method does not require having Docker installed on your machine. Lets say that I want to bootstrap tensorflow from Docker. First I should create the tensorflow image:
Note that if you want (much) more detailed output for debugging to the console, you need to enable --verbose mode:
Now I can shell into it, and import tensorflow:
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:
A CMD is to provide defaults for an executing container.
and
An ENTRYPOINT helps you to configure a container that you can run as an executable.
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:
Do a barrel role! Use a spec file! Many times, you want to bootstrap an image, and then either change the %runscript or add additional software or commands in the %post section. To achieve this, you can create a specification file. Currently, these are distributed with the naming format [myfile].def, however (soon) we will use a standard name, Singularity so all specification files can be automatically found. Here is what the spec file would look like for tensorflow:
In the example above, I am overriding any Dockerfile ENTRYPOINT because I have defined a %runscript. If I want the Dockerfile ENTRYPOINT to take preference, I would remove the %runscript section:
Note that the spec file above would be (almost) equivalent to the command:
minus the useless echo at the end. If I want the CMD to take preference, I would add IncludeCmd:
The solutions above would be ideal for saving a custom specification of an image to build at some runtime.
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:
You can simply specify your additional authentication parameters in the header with the labels Username and Password:
Again, this can be in addition to specification of a custom registry with the Registry parameter.
You can export your registry, username, and password for Singularity as follows:
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:
This should place the token in the environmental variable TOKEN. To test that your token is valid, you can do the following
The above call should return the tags list as expected.
Finally, we can achieve a shell experience, meaning shelling into Docker image imported into Singularity. We do this by storing the entire image in a temporary location, and then running the same function. You would do something like this:
A common use case is to want to start with a Docker image, possibly add custom commands, and have a Singularity image when you finish. You can read a bit about bootstrapping here to get a sense of adding the custom commands and software. To specify Docker as the build source, you simply need this header:
In the case of omitting the tag (latest) it is assumed that you want the latest image. In the case of omitting the namespace (library) it is assumed that you want the common namespace, library. If you have a reason to use the Docker Engine, we also have a method to do this. The benefit of this method would be that you could use an image built locally (in your local cache) that isnt on Docker Hub.
Here we will access Docker images via the Docker command line tool, meaning using the Docker engine. As is the Docker standard, the image is first looked for in your local cache, and if not found, is pulled from Docker Hub.
We wrapped this entire process into a Docker container itself, which means that you can use a Docker container in a Docker container to export a Docker container into Singularity! Nuts. Full instructions are provided, however here is the gist:
How did this come to be? It so happens that Docker has an export command to pipe this data out, and Singularity has an import command to take them in. Thus, you can do a simple import of a Docker image into a Singularity command by doing:
Where $container_id is the id of a running container obtained with docker ps. However, there are subtle details like the environment and permissions that this method will miss. Its also the case that most Docker images dont run (and stay running) easily unless you do something like:
Early on we created a docker2singularity.sh, a script that you can download and run as follows:
To produce a Singularity image of ubuntu:latest in the present working directory.
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.
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.
Excerpt from:
Singularity and Docker | Singularity
- Singularity University - Solving Humanity's Grand Challenges [Last Updated On: June 10th, 2016] [Originally Added On: June 10th, 2016]
- Singularity Viewer [Last Updated On: June 12th, 2016] [Originally Added On: June 12th, 2016]
- Technological singularity - Wikipedia, the free encyclopedia [Last Updated On: June 14th, 2016] [Originally Added On: June 14th, 2016]
- Singularity HUB - News and Insights on Technology, Science ... [Last Updated On: June 16th, 2016] [Originally Added On: June 16th, 2016]
- Singularity on Steam [Last Updated On: June 22nd, 2016] [Originally Added On: June 22nd, 2016]
- The Best Definition of Singularity [Last Updated On: June 22nd, 2016] [Originally Added On: June 22nd, 2016]
- Amazon.com: Singularity - Xbox 360: Video Games [Last Updated On: June 22nd, 2016] [Originally Added On: June 22nd, 2016]
- Singularity - Microsoft Research [Last Updated On: June 22nd, 2016] [Originally Added On: June 22nd, 2016]
- Singularity - GameSpot [Last Updated On: June 22nd, 2016] [Originally Added On: June 22nd, 2016]
- Singularity Q&A | KurzweilAI [Last Updated On: June 27th, 2016] [Originally Added On: June 27th, 2016]
- Singularity - RationalWiki [Last Updated On: July 18th, 2016] [Originally Added On: July 18th, 2016]
- Amazon.com: Singularity [Online Game Code]: Video Games [Last Updated On: August 25th, 2016] [Originally Added On: August 25th, 2016]
- Singularity - Mass Effect Wiki - Wikia [Last Updated On: August 25th, 2016] [Originally Added On: August 25th, 2016]
- Downloads - Singularity Viewer [Last Updated On: August 25th, 2016] [Originally Added On: August 25th, 2016]
- Singularity | Singularity [Last Updated On: October 31st, 2016] [Originally Added On: October 31st, 2016]
- What is Singularity (the)? - Definition from WhatIs.com [Last Updated On: October 31st, 2016] [Originally Added On: October 31st, 2016]
- Singularity University - Wikipedia [Last Updated On: November 29th, 2016] [Originally Added On: November 29th, 2016]
- Technological singularity - Wikipedia [Last Updated On: December 15th, 2016] [Originally Added On: December 15th, 2016]
- The Singularity Is Near - Wikipedia [Last Updated On: January 22nd, 2017] [Originally Added On: January 22nd, 2017]
- Singularity Art Show Tonight In San Francisco! [Last Updated On: January 23rd, 2017] [Originally Added On: January 23rd, 2017]
- When Electronic Witnesses Are Everywhere, No Secret's Safe - Singularity Hub [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- GEMS Education and Singularity University organises 1st annual Global Innovation Challenge - Al-Bawaba [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Do you believe in the Singularity? - Patheos (blog) [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Report: AMD Ryzen Performance in Ashes of the Singularity Benchmark - PC Perspective [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Donald Trump Is the Singularity - Bloomberg View - Bloomberg.com - Bloomberg [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Editorial Note From the Singularity Hub Team - Singularity Hub [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Discover the Most Advanced Industrial Technologies at Exponential Manufacturing - Singularity Hub [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- 10th Letter looks at nature in the time of the Singularity - Creative Loafing Atlanta [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- Wearable Devices Can Actually Tell When You're About to Get Sick - Singularity Hub [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- Video: Singularity Containers for Science, Reproducibility, and HPC - insideHPC [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- Robot Cars Can Teach Themselves How to Drive in Virtual Worlds - Singularity Hub [Last Updated On: February 9th, 2017] [Originally Added On: February 9th, 2017]
- Rowe FTC robotics team RSF Singularity takes top honors at Championship - Rancho Santa Fe Review [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- Physicists Unveil Blueprint for a Quantum Computer the Size of a ... - Singularity Hub [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- Singularity Containers for Science, Reproducibility, and HPC - Linux.com (blog) [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- How Robots Helped Create 100,000 Jobs at Amazon - Singularity Hub - Singularity Hub [Last Updated On: February 11th, 2017] [Originally Added On: February 11th, 2017]
- Ready to Change the World? Apply Now for Singularity University's 2017 Global Solutions Program - Singularity Hub [Last Updated On: February 11th, 2017] [Originally Added On: February 11th, 2017]
- Families Finally Hear From Completely Paralyzed Patients Via New Mind-Reading Device - Singularity Hub [Last Updated On: February 13th, 2017] [Originally Added On: February 13th, 2017]
- The fear of a technological singularity - ETtech.com [Last Updated On: February 13th, 2017] [Originally Added On: February 13th, 2017]
- Holograms Aren't The Stuff of Science Fiction Anymore - Singularity Hub [Last Updated On: February 15th, 2017] [Originally Added On: February 15th, 2017]
- How the World Has Changed From 1917 to 2017 - Singularity Hub [Last Updated On: February 15th, 2017] [Originally Added On: February 15th, 2017]
- Preparing for the Singularity - Inverse [Last Updated On: February 15th, 2017] [Originally Added On: February 15th, 2017]
- Ashes of the Singularity merges with standalone expansion Escalation, no upgrade fee - PCGamesN [Last Updated On: February 18th, 2017] [Originally Added On: February 18th, 2017]
- Just Stand Inside this Room and it Will Wirelessly Charge Your Phone - Singularity Hub [Last Updated On: February 18th, 2017] [Originally Added On: February 18th, 2017]
- Ashes of the Singularity: Escalation being merged with the original game - PC Invasion (blog) [Last Updated On: February 18th, 2017] [Originally Added On: February 18th, 2017]
- Europe's TREASURE Will Be the King of All GPSs - Singularity Hub [Last Updated On: February 18th, 2017] [Originally Added On: February 18th, 2017]
- AMD bundles Ashes of the Singularity with FX processors ahead of Ryzen's launch - PCWorld [Last Updated On: February 18th, 2017] [Originally Added On: February 18th, 2017]
- The roots of technological singularity can be traced backed to the Stone Age - Wired.co.uk [Last Updated On: February 20th, 2017] [Originally Added On: February 20th, 2017]
- Jide's new OS is like an Android version of Windows 10's Continuum - The Verge [Last Updated On: February 22nd, 2017] [Originally Added On: February 22nd, 2017]
- Jide's Remix Singularity OS will turn your Android phone into a PC - Android Authority (blog) [Last Updated On: February 22nd, 2017] [Originally Added On: February 22nd, 2017]
- Remix tries its hand at the mobile-desktop hybrid OS with Singularity - Android Police [Last Updated On: February 23rd, 2017] [Originally Added On: February 23rd, 2017]
- Financial Leaders: Make Your Mark on the Future at Exponential Finance - Singularity Hub [Last Updated On: February 23rd, 2017] [Originally Added On: February 23rd, 2017]
- After Man? From Singularity to Specificity - Peace Research Institute Oslo (PRIO) (press release) (blog) [Last Updated On: February 23rd, 2017] [Originally Added On: February 23rd, 2017]
- Ashes of Singularity: Escalation Gets an Update - CGMagazine [Last Updated On: February 24th, 2017] [Originally Added On: February 24th, 2017]
- One Android company wants to use smartphones to make PCs truly ... - BGR [Last Updated On: February 24th, 2017] [Originally Added On: February 24th, 2017]
- Jide Announces Remix Singularity: The Continuum Alternative for Android - XDA Developers (blog) [Last Updated On: February 24th, 2017] [Originally Added On: February 24th, 2017]
- Why the Potential of Augmented Reality Is Greater Than You Think - Singularity Hub [Last Updated On: February 24th, 2017] [Originally Added On: February 24th, 2017]
- Damon Wayans Jr. Will Star in Seth Rogen's AI Comedy 'Singularity' for FX - /FILM [Last Updated On: February 24th, 2017] [Originally Added On: February 24th, 2017]
- Google Updates: Scuba, Singularity, SMS and suing - The INQUIRER [Last Updated On: February 24th, 2017] [Originally Added On: February 24th, 2017]
- Damon Wayans Jr. Joins FX Sci-Fi Comedy Singularity - Den of Geek US [Last Updated On: February 28th, 2017] [Originally Added On: February 28th, 2017]
- This Neural Probe Is So Thin, The Brain Doesn't Know It's There - Singularity Hub [Last Updated On: February 28th, 2017] [Originally Added On: February 28th, 2017]
- Video: AI Is Getting Smarter, Says Singularity University's Neil Jacobstein - Wall Street Journal (subscription) (blog) [Last Updated On: February 28th, 2017] [Originally Added On: February 28th, 2017]
- Jami Attenberg's funny-sad 'All Grown Up' all about the singularity - Milwaukee Journal Sentinel [Last Updated On: February 28th, 2017] [Originally Added On: February 28th, 2017]
- Citizen Science Means Anyone Could Discover Planet NineEven You - Singularity Hub [Last Updated On: February 28th, 2017] [Originally Added On: February 28th, 2017]
- Does Zapping Your Brain Actually Help You Learn Faster? - Singularity Hub [Last Updated On: March 1st, 2017] [Originally Added On: March 1st, 2017]
- What You Need to Know About Elon Musk's Plan to Fly People to the Moon - Singularity Hub [Last Updated On: March 1st, 2017] [Originally Added On: March 1st, 2017]
- Singularity University opening organisation in Denmark The Post - The Copenhagen Post - Danish news in english [Last Updated On: March 1st, 2017] [Originally Added On: March 1st, 2017]
- Singularity: Explain It to Me Like I'm 5-Years-Old - Futurism - Futurism [Last Updated On: March 4th, 2017] [Originally Added On: March 4th, 2017]
- See How This House Was 3D Printed in Just 24 Hours - Singularity Hub [Last Updated On: March 5th, 2017] [Originally Added On: March 5th, 2017]
- NYC's Metrograph theater is running a sci-fi film series featuring Blade Runner, Ex Machina, and Metropolis - The Verge [Last Updated On: March 7th, 2017] [Originally Added On: March 7th, 2017]
- 3 Exciting Biotech Trends to Watch Closely in 2017 - Singularity Hub - Singularity Hub [Last Updated On: March 9th, 2017] [Originally Added On: March 9th, 2017]
- New Burger Robot Will Take Command of the Grill in 50 Fast Food Restaurants - Singularity Hub [Last Updated On: March 9th, 2017] [Originally Added On: March 9th, 2017]
- Are These Giant Neurons the Seat Of Consciousness in the Brain? - Singularity Hub [Last Updated On: March 10th, 2017] [Originally Added On: March 10th, 2017]
- How Fully Synthetic Complex Life Just Got a Lot Closer - Singularity Hub [Last Updated On: March 12th, 2017] [Originally Added On: March 12th, 2017]
- The Singularity is Coming in 2029 and Will Make Humans 'Sexier' - Inverse [Last Updated On: March 17th, 2017] [Originally Added On: March 17th, 2017]
- NYC Weekend Watch: 'Taipei Story,' the Singularity, 'The Last Movie' & More - The Film Stage (blog) [Last Updated On: March 17th, 2017] [Originally Added On: March 17th, 2017]
- The Singularity: US Navy calls on gamers to help it plan for the rise ... - International Business Times UK [Last Updated On: March 17th, 2017] [Originally Added On: March 17th, 2017]
- Have a big idea to tackle climate change? Singularity U's Global Impact Challenge wants you - Miami Herald [Last Updated On: March 17th, 2017] [Originally Added On: March 17th, 2017]
- The singularity: AI will make humans sexier and funnier, says ... - The Independent [Last Updated On: March 17th, 2017] [Originally Added On: March 17th, 2017]
- Silicon Valley's top brains try to sort out the singularity - TechEye [Last Updated On: March 21st, 2017] [Originally Added On: March 21st, 2017]
- World Order's 'Singularity' raises profile of singular girls group - Japan Today [Last Updated On: March 27th, 2017] [Originally Added On: March 27th, 2017]