Singularity Container Documentation Release 3.0
Total Page:16
File Type:pdf, Size:1020Kb
Singularity Container Documentation Release 3.0 User Docs Mar 25, 2019 CONTENTS 1 Quick Start 1 1.1 Quick Installation Steps.........................................1 1.1.1 Install system dependencies..................................1 1.1.2 Install Go............................................1 1.1.3 Clone the Singularity repository................................2 1.1.4 Install Go dependencies.....................................2 1.1.5 Compile the Singularity binary.................................2 1.2 Overview of the Singularity Interface..................................2 1.3 Download pre-built images........................................4 1.4 Interact with images...........................................5 1.4.1 Shell...............................................6 1.4.2 Executing Commands......................................6 1.4.3 Running a container.......................................7 1.4.4 Working with Files.......................................7 1.5 Build images from scratch........................................8 1.5.1 Sandbox Directories......................................8 1.5.2 Converting images from one format to another.........................8 1.5.3 Singularity Definition Files...................................9 2 Contributing 11 2.1 Join the community........................................... 11 2.1.1 Singularity Google Group................................... 11 2.1.2 Singularity on Slack...................................... 11 2.2 Raise an Issue.............................................. 11 2.3 Write Documentation.......................................... 11 2.4 Contribute to the code.......................................... 12 2.4.1 Step 1. Fork the repo...................................... 12 2.4.2 Step 2. Checkout a new branch................................. 12 2.4.3 Step 3. Make your changes................................... 12 2.4.4 Step 4. Push your branch to your fork............................. 13 2.4.5 Step 5. Submit a Pull Request................................. 13 2.4.6 Step 6. Keep your branch in sync................................ 13 3 Installation 15 3.1 Overview................................................. 15 3.2 Install on Linux.............................................. 15 3.2.1 Before you begin........................................ 15 3.2.1.1 Install Dependencies.................................. 15 3.2.1.2 Install Go....................................... 16 3.2.2 Install from source....................................... 16 i 3.2.2.1 Download Singularity repo (and optionally check out a tag or branch)........ 16 3.2.2.2 Download and install Singularity from a release................... 17 3.2.2.3 Compile Singularity.................................. 17 3.2.2.4 Source bash completion file.............................. 18 3.2.3 Build and install an RPM.................................... 18 3.2.4 Remove an old version..................................... 18 3.2.5 Distribution packages of Singularity.............................. 19 3.2.5.1 Install the Debian/Ubuntu package using apt .................... 19 3.2.5.2 Install the CentOS/RHEL package using yum .................... 20 3.3 Install on Windows or Mac........................................ 20 3.3.1 Setup.............................................. 21 3.3.1.1 Windows........................................ 21 3.3.1.2 Mac.......................................... 21 3.3.2 Singularity Vagrant Box.................................... 21 3.4 Singularity on a shared resource..................................... 22 4 Command Line Interface 25 5 Build a Container 27 5.1 Overview................................................. 27 5.2 Downloading an existing container from the Container Library..................... 27 5.3 Downloading an existing container from Docker Hub.......................... 28 5.4 Creating writable --sandbox directories............................... 28 5.5 Converting containers from one format to another............................ 28 5.6 Building containers from Singularity definition files.......................... 28 5.7 Build options............................................... 29 5.7.1 --builder .......................................... 29 5.7.2 --detached ......................................... 29 5.7.3 --force ............................................ 29 5.7.4 --json ............................................. 29 5.7.5 --library .......................................... 29 5.7.6 --notest ........................................... 30 5.7.7 --remote ........................................... 30 5.7.8 --sandbox .......................................... 30 5.7.9 --section .......................................... 30 5.7.10 --update ........................................... 30 5.8 More Build topics............................................ 30 6 Definition Files 31 6.1 Overview................................................. 31 6.2 Header.................................................. 31 6.3 Sections.................................................. 32 6.3.1 %setup............................................. 33 6.3.2 %files.............................................. 33 6.3.3 %environment.......................................... 34 6.3.4 %post.............................................. 34 6.3.5 %runscript............................................ 35 6.3.6 %startscript........................................... 35 6.3.7 %test.............................................. 36 6.3.8 %labels............................................. 36 6.3.9 %help.............................................. 37 6.4 Apps................................................... 37 6.5 Best Practices for Build Recipes..................................... 39 7 Build Environment 41 ii 7.1 Overview................................................. 41 7.2 Cache Folders.............................................. 41 7.3 Temporary Folders............................................ 41 7.4 Pull Folder................................................ 42 7.5 Environment Variables.......................................... 42 7.5.1 Defaults............................................. 42 7.5.1.1 Docker......................................... 42 7.5.1.2 Library......................................... 42 8 Support for Docker and OCI 43 8.1 Overview................................................. 43 8.2 Running action commands on public images from Docker Hub.................... 43 8.3 Making use of public images from Docker Hub............................. 46 8.4 Making use of private images from Docker Hub............................ 47 8.4.1 Authentication via Interactive Login.............................. 48 8.4.2 Authentication via Environment Variables........................... 48 8.5 Making use of private images from Private Registries.......................... 49 8.6 Building images for Singularity from Docker Registries........................ 50 8.6.1 Working from the Singularity Command Line......................... 50 8.6.1.1 Remotely Hosted Images............................... 50 8.6.1.2 Building Containers Remotely............................ 52 8.6.1.3 Locally Available Images: Cached by Docker.................... 53 8.6.1.4 Locally Available Images: Stored Archives...................... 54 8.6.1.5 Pushing Locally Available Images to a Library.................... 56 8.6.2 Working with Definition Files................................. 58 8.6.2.1 Mandatory Header Keywords: Remotely Boostrapped................ 58 8.6.2.2 Remotely Bootstrapped and Built Containers..................... 59 8.6.2.3 Mandatory Header Keywords: Locally Boostrapped................. 61 8.6.2.4 Optional Header Keywords.............................. 62 8.6.2.5 Private Images and Registries............................. 63 8.6.2.6 Directing Execution.................................. 63 8.6.2.7 Container Metadata.................................. 65 8.7 OCI Image Support............................................ 66 8.7.1 Overview............................................ 66 8.7.1.1 Image Pulls Revisited................................. 66 8.7.1.2 Image Caching in Singularity............................. 67 8.7.1.3 Compliance with the OCI Image Layout Specification................ 67 8.7.1.4 OCI Compliance and the Singularity Cache..................... 68 8.7.2 Building Containers for Singularity from OCI Images..................... 71 8.7.2.1 Working Locally from the Singularity Command Line: oci Boostrap Agent.... 71 8.7.2.2 Working Locally from the Singularity Command Line: oci-archive Boostrap Agent......................................... 72 8.7.2.3 Working from the Singularity Command Line with Remotely Hosted Images.... 74 8.7.2.4 Working with Definition Files: Mandatory Header Keywords............ 75 8.7.2.5 Working with Definition Files: Additonal Considerations.............. 76 8.8 Best Practices............................................... 77 8.9 Troubleshooting............................................. 79 9 Bind Paths and Mounts 81 9.1 Overview................................................. 81 9.2 System-defined bind paths........................................ 81 9.3 User-defined bind paths......................................... 81 9.3.1 Specifying bind paths...................................... 81 9.3.2 A note on using --bind with the --writable flag.................... 82 iii 10 Persistent Overlays 83 10.1 Overview................................................. 83 10.2 Usage..................................................