From ee7e6bacf25514e74f7f5e0844371ae03e8ddd85 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 9 Feb 2017 18:49:47 -0800 Subject: [PATCH 1/7] Quick hints to build a CentOS 7 image. It was frustrating to try to start quickly via the Quick Start and not have any idea where to find an image. There are hints in the README in the repo, but it's convenient to have them here. I pulled the content from the README.md and referenced it and the tutorials section. "Someone" should probably work up a posse of examples for the Linux Flavors du jour. --- pages/docs/overview/start.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index 12d2652..dcca71d 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -19,6 +19,29 @@ sudo make install ## Command Quick Start +### Create a Centos7 image from a CentOS host + +It's easiest to build an image on a "compatible" host. Here's a quick +recipe to build a CentOS 7 image on a CentOS host. See +the [bootstrapping section][bootstrapping-readme] of the README for +the backstory and the [tutorials] for deeper advice. + +1. Create a file named `centos.def` that contains the following lines. + + ``` + BootStrap: yum + OSVersion: 7 + MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/$basearch/ + Include: yum + ``` + +2. Create and bootstrap the image: + + ```bash + $ sudo singularity create /tmp/Centos-7.img + $ sudo singularity bootstrap /tmp/Centos-7.img centos.def + ``` + ### Shell into container ```bash singularity shell --contain /tmp/Centos7.img @@ -64,3 +87,5 @@ DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS" ```` {% include links.html %} + +[readme-bootstrapping]: https://github.com/singularityware/singularity/blob/master/README.md#bootstrapping-new-images From 688f4be59a2b5e2453abb156d367dfad4df0b15f Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 9 Feb 2017 18:53:06 -0800 Subject: [PATCH 2/7] Add shell prompts to the examples Make the examples consistent-ish with the examples in the README.md by adding the traditional '$' shell prompt where appropriate. --- pages/docs/overview/start.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index dcca71d..4dab727 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -44,7 +44,7 @@ the backstory and the [tutorials] for deeper advice. ### Shell into container ```bash -singularity shell --contain /tmp/Centos7.img +$ singularity shell --contain /tmp/Centos7.img Singularity.Centos7.img> ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND gmk 1 0.0 0.3 115372 1768 pts/6 S 12:23 0:00 /bin/bash --norc --noprofile @@ -55,31 +55,31 @@ Singularity.Centos7.img> exit ### I am the same user inside the container as outside the container ```bash -id +$ id uid=1000(gmk) gid=1000(gmk) groups=1000(gmk),10(wheel),2222(testgroup) -singularity exec /tmp/Centos7.img id +$ singularity exec /tmp/Centos7.img id uid=1000(gmk) gid=1000(gmk) groups=1000(gmk),10(wheel),2222(testgroup) ```` ### Files on the host can be reachable from within the container ```bash -echo "Hello World" > /home/gmk/testfile -singularity exec /tmp/Centos7.img cat /home/gmk/testfile +$ echo "Hello World" > /home/gmk/testfile +$ singularity exec /tmp/Centos7.img cat /home/gmk/testfile Hello World ```` ### Switching operating systems is as easy as pointing to a different image! ```bash -singularity exec /tmp/Centos7.img cat /etc/redhat-release +$ singularity exec /tmp/Centos7.img cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) -singularity exec /tmp/SL6.img cat /etc/redhat-release +$ singularity exec /tmp/SL6.img cat /etc/redhat-release Scientific Linux release 6.8 (Carbon) -singularity exec /tmp/Debian-stable.img cat /etc/debian_version +$ singularity exec /tmp/Debian-stable.img cat /etc/debian_version 8.5 -singularity exec /tmp/Ubuntu-trusty.img cat /etc/lsb-release +$ singularity exec /tmp/Ubuntu-trusty.img cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty From e252b2fe4bfdbc12dbeb1ac2732a356458ee14d4 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 9 Feb 2017 18:56:00 -0800 Subject: [PATCH 3/7] Fix broken link to README.md --- pages/docs/overview/start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index 4dab727..7e41727 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -23,7 +23,7 @@ sudo make install It's easiest to build an image on a "compatible" host. Here's a quick recipe to build a CentOS 7 image on a CentOS host. See -the [bootstrapping section][bootstrapping-readme] of the README for +the [bootstrapping section][readme-bootstrapping] of the README for the backstory and the [tutorials] for deeper advice. 1. Create a file named `centos.def` that contains the following lines. From 3f31b2602d65896502dfe30107e98e59822835cb Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 9 Feb 2017 18:56:15 -0800 Subject: [PATCH 4/7] Add prompts to the Installation quick start As in the earlier commit, add shell prompts to the lines in the example, making them consistent with other examples here and in the README.md. --- pages/docs/overview/start.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index 7e41727..212cd34 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -9,12 +9,12 @@ toc: false ## Installation Quick Start ```bash -git clone {{ site.repo }}.git -cd singularity -./autogen.sh -./configure --prefix=/usr/local -make -sudo make install +$ git clone {{ site.repo }}.git +$ cd singularity +$ ./autogen.sh +$ ./configure --prefix=/usr/local +$ make +$ sudo make install ``` ## Command Quick Start From d8115103787993668aef1fdcf744263eeb40ce97 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 9 Feb 2017 19:01:21 -0800 Subject: [PATCH 5/7] Fix image name (quickstart differs from README.md) --- pages/docs/overview/start.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index 212cd34..539fd3d 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -38,8 +38,8 @@ the backstory and the [tutorials] for deeper advice. 2. Create and bootstrap the image: ```bash - $ sudo singularity create /tmp/Centos-7.img - $ sudo singularity bootstrap /tmp/Centos-7.img centos.def + $ sudo singularity create /tmp/Centos7.img + $ sudo singularity bootstrap /tmp/Centos7.img centos.def ``` ### Shell into container From 6516211ee37e60d836598f2f0e6c970df57ca1b6 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Thu, 9 Feb 2017 19:03:25 -0800 Subject: [PATCH 6/7] Wordsmithing --- pages/docs/overview/start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index 539fd3d..2ba1f6a 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -24,7 +24,7 @@ $ sudo make install It's easiest to build an image on a "compatible" host. Here's a quick recipe to build a CentOS 7 image on a CentOS host. See the [bootstrapping section][readme-bootstrapping] of the README for -the backstory and the [tutorials] for deeper advice. +the full story and the [tutorials] for deeper advice. 1. Create a file named `centos.def` that contains the following lines. From 68f0bf5b11fe9a585d475fc8a72d96632d0887f1 Mon Sep 17 00:00:00 2001 From: George Hartzell Date: Sat, 11 Feb 2017 13:32:43 -0800 Subject: [PATCH 7/7] Rework example to pull image from Docker Hub Pulling an existing image from Docker Hub will make it easier for a wider range of Linux users to get going quickly. Rework the demo to import a CentOS 7 image. Give a few other popular Linuxes a shout out and refer to the Singularity and Docker page. --- pages/docs/overview/start.md | 56 ++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/pages/docs/overview/start.md b/pages/docs/overview/start.md index 2ba1f6a..32aa75e 100644 --- a/pages/docs/overview/start.md +++ b/pages/docs/overview/start.md @@ -19,28 +19,41 @@ $ sudo make install ## Command Quick Start -### Create a Centos7 image from a CentOS host - -It's easiest to build an image on a "compatible" host. Here's a quick -recipe to build a CentOS 7 image on a CentOS host. See -the [bootstrapping section][readme-bootstrapping] of the README for -the full story and the [tutorials] for deeper advice. - -1. Create a file named `centos.def` that contains the following lines. - - ``` - BootStrap: yum - OSVersion: 7 - MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/$basearch/ - Include: yum - ``` - -2. Create and bootstrap the image: +### Import a Centos7 image from Docker Hub + +The quickest way to get an image is to import it from Docker Hub. +Here's an example that creates an empty image, imports the current +CentOS 7 Docker image and proves that we got what we wanted. + +```terminal +$ singularity create /tmp/Centos7.img +Creating a new image with a maximum size of 768MiB... +Executing image create helper +Formatting image with ext3 file system +Done. +$ singularity import /tmp/Centos7.img docker://centos:7 +Cache folder set to /root/.singularity/docker +Extracting /root/.singularity/docker/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4.tar.gz +Extracting /root/.singularity/docker/sha256:45a2e645736c4c66ef34acce2407ded21f7a9b231199d3b92d6c9776df264729.tar.gz +Bootstrap initialization +No bootstrap definition passed, updating container +Executing Prebootstrap module +Executing Postbootstrap module +Done. +$ singularity shell --contain /tmp/Centos7.img +Singularity: Invoking an interactive shell within container... + +Singularity.Centos7.img> cat /etc/redhat-release +CentOS Linux release 7.3.1611 (Core) +Singularity.Centos7.img> exit +exit +$ +``` - ```bash - $ sudo singularity create /tmp/Centos7.img - $ sudo singularity bootstrap /tmp/Centos7.img centos.def - ``` +This approach works with Docker's basic Alpine Linux +(`docker://alpine`), Debian (`docker://debian`), Ubuntu +(`docker://ubuntu`) and more. You'll find the details on +the [Singularity and Docker][docs-docker] page. ### Shell into container ```bash @@ -88,4 +101,5 @@ DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS" {% include links.html %} +[docs-docker]: /docs-docker [readme-bootstrapping]: https://github.com/singularityware/singularity/blob/master/README.md#bootstrapping-new-images