Skip to content

Commit 8c4bf0e

Browse files
committed
updating docker docs to mention registry/namespace
1 parent dee855c commit 8c4bf0e

1 file changed

Lines changed: 43 additions & 46 deletions

File tree

pages/docs/user-docs/docs-docker.md

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,70 +35,61 @@ The core of a Docker image is basically a compressed set of files, a set of `.ta
3535

3636

3737
## Quick Start: The Docker Registry
38-
The Docker engine communicates with the Docker Hub via the <a href="https://docs.docker.com/engine/reference/api/docker_remote_api/" target="_blank">Docker Remote API</a>, 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 don't need Docker installed on your machine, but you will need a working internet connection. Let's create an ubuntu operating system, from Docker:
38+
The Docker engine communicates with the Docker Hub via the <a href="https://docs.docker.com/engine/reference/api/docker_remote_api/" target="_blank">Docker Remote API</a>, 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 don't need Docker installed on your machine, but you will need a working internet connection. Let's create an ubuntu operating system, from Docker. We will pull, then build:
3939

40-
```bash
41-
singularity create ubuntu.img
42-
Initializing Singularity image subsystem
43-
Opening image file: ubuntu.img
44-
Creating 768MiB image
45-
Binding image to loop
46-
Creating file system within image
47-
Image is done: ubuntu.img
48-
```
49-
50-
Note that the default size is 768MB, you can modify this by adding the `--size` or `-s` argument like:
51-
52-
```bash
53-
singularity create --size 2000 ubuntu.img
54-
```
55-
56-
If you aren't sure about the size? Try <a href="https://asciinema.org/a/103492?speed=3" target="_blank">building into a folder first</a>.
57-
58-
```bash
59-
mkdir fatty
60-
singularity import fatty docker://ubuntu:latest
61-
du -sh fatty/
62-
```
63-
64-
Next, let's import a Docker image into it!
6540

6641
```bash
67-
singularity import ubuntu.img docker://ubuntu
42+
singularity pull docker://ubuntu
43+
WARNING: pull for Docker Hub is not guaranteed to produce the
44+
WARNING: same image on repeated pull. Use Singularity Registry
45+
WARNING: (shub://) to pull exactly equivalent images.
46+
Docker image path: index.docker.io/library/ubuntu:latest
6847
Cache folder set to /home/vanessa/.singularity/docker
48+
[5/5] |===================================| 100.0%
6949
Importing: base Singularity environment
70-
Importing: /home/vanessa/.singularity/docker/sha256:6d9ef359eaaa311860550b478790123c4b22a2eaede8f8f46691b0b4433c08cf.tar.gz
71-
Importing: /home/vanessa/.singularity/docker/sha256:9654c40e9079e3d5b271ec71f6d83f8ce80cfa6f09d9737fc6bfd4d2456fed3f.tar.gz
72-
Importing: /home/vanessa/.singularity/docker/sha256:e8db7bf7c39fab6fec91b1b61e3914f21e60233c9823dd57c60bc360191aaf0d.tar.gz
73-
Importing: /home/vanessa/.singularity/docker/sha256:f8b845f45a87dc7c095b15f3d9661e640ebc86f42cd8e8ab36674846472027f7.tar.gz
74-
Importing: /home/vanessa/.singularity/docker/sha256:d54efb8db41d4ac23d29469940ec92da94c9a6c2d9e26ec060bebad1d1b0e48d.tar.gz
75-
Importing: /home/vanessa/.singularity/docker/sha256:fe44851d529f465f9aa107b32351c8a0a722fc0619a2a7c22b058084fac068a4.tar.gz
76-
singularity shell ubuntu.img
77-
Singularity: Invoking an interactive shell within container...
78-
79-
Singularity ubuntu.img>
50+
Importing: /home/vanessa/.singularity/docker/sha256:9fb6c798fa41e509b58bccc5c29654c3ff4648b608f5daa67c1aab6a7d02c118.tar.gz
51+
Importing: /home/vanessa/.singularity/docker/sha256:3b61febd4aefe982e0cb9c696d415137384d1a01052b50a85aae46439e15e49a.tar.gz
52+
Importing: /home/vanessa/.singularity/docker/sha256:9d99b9777eb02b8943c0e72d7a7baec5c782f8fd976825c9d3fb48b3101aacc2.tar.gz
53+
Importing: /home/vanessa/.singularity/docker/sha256:d010c8cf75d7eb5d2504d5ffa0d19696e8d745a457dd8d28ec6dd41d3763617e.tar.gz
54+
Importing: /home/vanessa/.singularity/docker/sha256:7fac07fb303e0589b9c23e6f49d5dc1ff9d6f3c8c88cabe768b430bdb47f03a9.tar.gz
55+
Importing: /home/vanessa/.singularity/metadata/sha256:77cece4ce6ef220f66747bb02205a00d9ca5ad0c0a6eea1760d34c744ef7b231.tar.gz
56+
WARNING: Building container as an unprivileged user. If you run this container as root
57+
WARNING: it may be missing some functionality.
58+
Building Singularity image...
59+
Cleaning up...
60+
Singularity container built: ./ubuntu.img
8061
```
8162

63+
The warnings mean well - it is to tell you that you are creating the image on the fly from layers, and if one of those layers changes, you won't produce the same image next time.
64+
8265
## The Build Specification file, Singularity
83-
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 let's talk about how to make these files! First, let's look at the absolute minimum requirement:
66+
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 sandbox (building with `--sandbox`) or to a build with `--writable` is by default not recorded, and your container loses its reproducibility. So let's talk about how to make these files! First, let's look at the absolute minimum requirement:
8467

8568
```bash
8669
Bootstrap: docker
87-
From: tensorflow/tensorflow:latest
70+
From: ubuntu
8871
```
8972

9073
We would save this content to a file called `Singularity` and then issue the following commands to bootstrap the image from the file
9174

9275
```bash
93-
singularity create --size 4000 tensorflow.img
94-
sudo singularity bootstrap tensorflow.img Singularity
76+
sudo singularity build ubuntu.img Singularity
9577
```
9678

97-
but just those two lines and doing bootstrap is silly, because we would achieve the same thing by doing:
79+
Do you want to specify a particular tag? or version? You can just add that to the docker uri:
9880

99-
```bash
100-
singularity create --size 4000 tensorflow.img
101-
singularity import tensorflow.img docker://tensorflow/tensorflow:latest
81+
```
82+
Bootstrap: docker
83+
From: ubuntu:latest
84+
```
85+
86+
Note that the default is `latest`. If you want to customize the Registry or Namespace, just add those to the header:
87+
88+
```
89+
Bootstrap: docker
90+
From: ubuntu
91+
Registry: pancakes.registry.index.io
92+
Namespace: blue/berry/cream
10293
```
10394

10495
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:
@@ -194,9 +185,15 @@ docker://index.docker.io/library/ubuntu@sha256:1235...
194185

195186
You can have one or the other, both are considered a "digest" in Docker speak.
196187

197-
If you want to change any of those fields, then just specify what you want in the URI.
188+
If you want to change any of those fields and are having trouble with the uri, you can also just state them explicitly:
198189

199190

191+
```
192+
Bootstrap: docker
193+
From: ubuntu
194+
Registry: index.docker.io
195+
Namespace: library
196+
```
200197

201198
## Custom Authentication
202199
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:

0 commit comments

Comments
 (0)