Skip to content

Commit 26dabbe

Browse files
committed
book: Move /opt redirection guidance to building
This is where I expected to find it. Signed-off-by: Colin Walters <[email protected]>
1 parent 9e424c2 commit 26dabbe

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
book
2+
mermaid*.js

docs/src/building/guidance.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,35 @@ for example, although this can run afoul of SELinux labeling.
138138

139139
There is a dedicated document for [secrets](secrets.md),
140140
which is a special case of configuration.
141+
142+
## Handling read-only vs writable locations
143+
144+
The high level pattern for bootc systems is summarized again
145+
this way:
146+
147+
- Put read-only data and executables in `/usr`
148+
- Put configuration files in `/usr` (if they're static), or `/etc` if they need to be machine-local
149+
- Put "data" (log files, databases, etc.) underneath `/var`
150+
151+
However, some software installs to `/opt/examplepkg` or another
152+
location outside of `/usr`, and may include all three types of data
153+
undernath its single toplevel directory. For example, it
154+
may write log files to `/opt/examplepkg/logs`. A simple way to handle
155+
this is to change the directories that need to be writble to symbolic links
156+
to `/var`:
157+
158+
```dockerfile
159+
RUN apt|dnf install examplepkg && \
160+
mv /opt/examplepkg/logs && /var/log/examplepkg && \
161+
ln -sr /opt/examplepkg/logs /var/log/examplepkg
162+
```
163+
164+
The [Fedora/CentOS bootc puppet example](https://gitlab.com/fedora/bootc/examples/-/tree/main/opt-puppet)
165+
is one instance of this.
166+
167+
Another option is to configure the systemd unit launching the service to do these mounts
168+
dynamically via e.g.
169+
170+
```
171+
BindPaths=/var/log/exampleapp:/opt/exampleapp/logs
172+
```

docs/src/filesystem.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,11 @@ Besides those, for other toplevel directories such as `/usr` `/opt`, they will b
121121
In the default suggested model of using composefs (per above) the `/opt` directory will be read-only, alongside
122122
other toplevels such as `/usr`.
123123

124-
Some software expects to be able to write to its own directory in `/opt/exampleapp`. A common
125-
pattern is to use a symbolic link to redirect to e.g. `/var` for things like log files:
124+
Some software (especially "3rd party" deb/rpm packages) expect to be able to write to
125+
a subdirectory of `/opt` such as `/opt/examplepkg`.
126126

127-
```
128-
RUN rmdir /opt/exampleapp/logs && ln -sr /var/log/exampleapp /opt/exampleapp/logs
129-
```
130-
131-
Another option is to configure the systemd unit launching the service to do these mounts
132-
dynamically via e.g.
133-
```
134-
BindPaths=/var/log/exampleapp:/opt/exampleapp/logs
135-
```
127+
See [building images](building/guidance.md) for recommendations on how to build
128+
container images and adjust the filesystem for cases like this.
136129

137130
#### Enabling transient root
138131

@@ -145,4 +138,4 @@ transient = true
145138
```
146139

147140
option in `prepare-root.conf`. In particular this will allow software to write (transiently) to `/opt`,
148-
with symlinks to `/var` for content that should persist.
141+
with symlinks to `/var` for content that should persist.

0 commit comments

Comments
 (0)