archil client in one of two ways:
- Mount on the host and bind into containers. The containers need no extra privileges. Use this when you control the host.
- Mount inside the container. Each container mounts the disk itself, which needs
/dev/fuseand theSYS_ADMINcapability. Use this when the container should carry its own mount, such as replicas spread across hosts.
Mount on the host and bind into containers
Install the client on the host and mount the disk, as described in Mount on Linux:rslave propagation:
compose.yaml
docker run, add :rslave to the volume:
rslave makes the container follow the host’s mounts. Without it, Docker takes a private copy of the bind mount when the
container starts:
- A container that starts before the disk is mounted sees an empty directory until you restart it.
- A container that starts while the disk is mounted keeps its own copy of the mount, and
archil unmounton the host waits until that container stops.
rslave, the disk appears in running containers as soon as the host mounts it, and a remount on the host shows up
without restarting them. While the disk is unmounted, /data is the empty directory underneath.
Every container on the host shares the host’s single mount, so any number of containers on one host can read and write
the disk with no extra flags.
Mount inside the container
The container needs three things to mount a disk:- The
/dev/fusedevice. - The
SYS_ADMINcapability, which allows themountcall. - On hosts that use AppArmor, such as Ubuntu and Debian,
apparmor:unconfined. Docker’s default AppArmor profile blocksmount.
--privileged.
Install the client in your image:
Dockerfile
entrypoint.sh
chmod +x entrypoint.sh. The Compose file grants the device and capability, and passes the token
as a Docker secret:
compose.yaml
.dockerignore
archil_mount_token.txt, then start the service:
You can also put
ARCHIL_DISK and ARCHIL_REGION in a .env file next to compose.yaml.Credentials
Keep disk tokens out of your images. Don’t put them in a DockerfileENV or ARG, and don’t COPY them into the image.
-
Docker secrets (recommended). Compose mounts the file at
/run/secrets/archil_mount_token, and the entrypoint above reads it. The token doesn’t appear indocker inspect. -
Environment variable. Pass
ARCHIL_MOUNT_TOKENfrom the shell that runs Compose. This is simpler, but anyone who can rundocker inspecton the container can read the token.compose.yaml
Share one disk across containers and hosts
On a single host, mount the disk once on the host and bind it into every container that needs it, as shown above. When several containers or hosts each mount the disk, choose a mount mode. By default,archil mount takes exclusive
ownership of the disk, so only one client can mount it for writing. To let many clients mount it at once, use one of:
--conditional: every client can write anywhere on the disk withoutarchil checkout. Use this when several replicas write to the same disk.--shared: the disk is read-only to each client until it runsarchil checkout <path>, which gives that client exclusive write access to the path.
ARCHIL_MOUNT_FLAGS to archil mount. To run two replicas of the service against one disk:
--shared, check out a directory before writing to it, and check it in when you’re done:
Shut down cleanly
Always unmount witharchil unmount, which flushes data that hasn’t reached the disk yet and releases the disk for other
clients.
-
Mounted inside the container.
docker stopanddocker compose downsendSIGTERMonly to the container’s main process, and everything else in the container is killed when it exits. The entrypoint above handlesSIGTERMby stopping your command and runningarchil unmountfirst. Setstop_grace_periodlong enough for the unmount to finish. -
Mounted on the host. Stop the containers first, then unmount:
A container whose bind mount doesn’t use
rslavekeeps the disk mounted, andarchil unmountwaits until it stops.