Skip to content

Commit 40ccd78

Browse files
GodloveDvsoch
authored andcommitted
adding page about overlayfs (#129)
1 parent 5d87653 commit 40ccd78

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

_data/sidebars/user_docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ entries:
3939
url: /docs-mount
4040
output: web, pdf
4141

42+
- title: Persistent Overlays
43+
url: /docs-overlay
44+
output: web, pdf
45+
4246
- title: Running Services
4347
url: /docs-instances
4448
output: web, pdf
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Working with Persistent Overlays
3+
sidebar: user_docs
4+
permalink: docs-overlay
5+
folder: docs
6+
toc: false
7+
---
8+
9+
Persistent overlay images are new to version 2.4! This feature allows you to overlay a writable file system on an immutable read-only container for the illusion of read-write access.
10+
11+
{% include toc.html %}
12+
13+
## Overview
14+
A persistent overlay is an image that "sits on top" of your compressed, immutable squashfs container. When you install new software or create and modify files the overlay image stores the changes.
15+
16+
In Singularity versions 2.4 and later an overlay file system is automatically added to your squashfs or sandbox container when it is mounted. This means you can install new software and create and modify files even though your container is read-only. But your changes will disappear as soon as you exit the container.
17+
18+
If you want your changes to persist in your container across uses, you can create a writable image to use as a persistent overlay. Then you can specify that you want to use the image as an overlay at runtime with the `--overlay` option.
19+
20+
You can use a persistent overlays with the following commands:
21+
22+
- `run`
23+
- `exec`
24+
- `shell`
25+
- `instance.start`
26+
27+
## Usage
28+
To use a persistent overlay, you must first have a container.
29+
30+
```
31+
$ singularity build ubuntu.simg shub://GodloveD/ubuntu
32+
```
33+
34+
Then you must create a writable, ext3 image. We can do so with the `image.create` command:
35+
36+
```
37+
$ singularity image.create my-overlay.img
38+
```
39+
40+
Now you can use this overlay image with your container. Note that it is not necessary to be root to use an overlay partition, but this will ensure that we have write privileges where we want them.
41+
42+
```
43+
$ sudo singularity shell --overlay my-overlay.img ubuntu.simg
44+
Singularity ubuntu.simg:~> touch /foo
45+
Singularity ubuntu.simg:~> apt-get install -y vim
46+
Singularity ubuntu.simg:~> which vim
47+
/usr/bin/vim
48+
Singularity ubuntu.simg:~> exit
49+
```
50+
51+
You will find that your changes persist across sessions as though you were using a writable container.
52+
53+
```
54+
$ sudo singularity shell --overlay my-overlay.img ubuntu.simg
55+
Singularity ubuntu.simg:~> ls /foo
56+
/foo
57+
Singularity ubuntu.simg:~> which vim
58+
/usr/bin/vim
59+
Singularity ubuntu.simg:~> exit
60+
```
61+
62+
If you mount your container without the `--overlay` option, your changes will be gone.
63+
64+
```
65+
$ sudo singularity shell ubuntu.simg
66+
Singularity ubuntu.simg:~> ls foo
67+
ls: cannot access 'foo': No such file or directory
68+
Singularity ubuntu.simg:~> which vim
69+
Singularity ubuntu.simg:~> exit
70+
```

0 commit comments

Comments
 (0)