Store the data in a folder of your choice
By default, Docker keeps the data of Kinlore in Docker volumes. Docker manages these volumes in its own folder. The file deploy/docker/bind-mounts.yml puts all data in one folder that you choose instead.
What you get
- All data of the server in one folder, for example on a large second disk.
- One subfolder for each service, so you see where the space goes.
- Simple backups: stop the server and copy the folder.
The server works the same way with or without this file.
The folder layout
The setting DATA_LOCATION in .env names the folder. The default is /srv/data/kinlore.
/srv/data/kinlore/
├── postgres/ the database
├── seaweedfs/
│ ├── master/ media storage: the list of storage parts
│ ├── volume/ media storage: all photos and videos
│ └── filer/ media storage: the file names
├── redis/ cache and rate limits
├── api/
│ └── storage/ logs, sessions and finished exports
└── caddy/
├── data/ HTTPS certificates
└── config/ web server stateEach service writes as its own user. Docker makes the missing folders at the first start, and each service sets the owner of its folder. You do not have to make the folders or change owners.
| Folder | Owner (user ID) |
|---|---|
postgres | 70 (postgres in the container) |
redis | 999 (redis in the container) |
api/storage | 82 (www-data in the container) |
| All others | 0 (root) |
Use a local disk with a Linux file system
Use a file system such as ext4 or XFS. A network share (NFS, SMB) or a disk with FAT or NTFS often does not keep the owner of a file. Then the database cannot start.
Turn it on for a new install
Do this before the first start.
- Add two lines to
.envnext todocker-compose.yml:diffUse a full path that starts with+COMPOSE_FILE=docker-compose.yml:deploy/docker/bind-mounts.yml +DATA_LOCATION=/srv/data/kinlore/. Docker Compose readsCOMPOSE_FILEfrom.envby itself. - Start the server:sh
docker compose up -d --build - Check that the data is in the folder:shEach subfolder of the layout above is in the list.
sudo du -sh /srv/data/kinlore/*
Also behind a reverse proxy?
Put both files in one line, separated by colons: COMPOSE_FILE=docker-compose.yml:deploy/docker/reverse-proxy.yml:deploy/docker/bind-mounts.yml. See HTTPS and reverse proxy.
Move an existing install
These steps copy the data from the Docker volumes into the folder. The volumes stay as they are, so you can go back.
The server is offline during the copy. The copy needs as much free space as the volumes use. docker system df -v shows the size of each volume.
Never use docker compose down -v
The option -v deletes the volumes, and with them all photos and videos. The steps below use docker compose down without -v.
- Go to the folder with
docker-compose.yml. Set two shell variables: the project name, and the new data folder.shPROJECT=$(docker compose config | sed -n 's/^name: //p') DATA_LOCATION=/srv/data/kinlore echo "$PROJECT" ls -A "$DATA_LOCATION"echoprints the project name, for examplekinlore-server.lsmust print nothing, orNo such file or directory. If it lists files, pick an empty folder. - Stop the server:sh
docker compose down - Copy each volume into its subfolder. A small throwaway container does the copy.
cp -akeeps the owner and the rights of each file.shEach volume prints onefor pair in postgres_data:postgres seaweedfs_master:seaweedfs/master \ seaweedfs_volume:seaweedfs/volume seaweedfs_filer:seaweedfs/filer \ redis_data:redis api_storage:api/storage caddy_data:caddy/data caddy_config:caddy/config; do vol="${PROJECT}_${pair%%:*}"; dir="$DATA_LOCATION/${pair#*:}" docker volume inspect "$vol" >/dev/null || { echo "Missing volume: $vol"; continue; } docker run --rm -v "$vol:/from:ro" -v "$dir:/to" alpine cp -a /from/. /to/ && echo "Copied $vol to $dir" doneCopiedline. If a line saysMissing volume, check the project name of step 1. - Turn the file on in
.env. If you already use other files inCOMPOSE_FILE, keep them and add the new one at the end.diff+COMPOSE_FILE=docker-compose.yml:deploy/docker/bind-mounts.yml +DATA_LOCATION=/srv/data/kinlore - Start the server:sh
docker compose up -d - Check that the server uses the folder, and that your data is there:shThe first command prints
docker inspect kinlore-postgres --format '{{range .Mounts}}{{.Type}} {{.Source}}{{end}}' sudo du -sh "$DATA_LOCATION"/* docker compose exec api curl -fsS http://localhost:8080/api/healthbind /srv/data/kinlore/postgres. Then open the app and check that your moments and their photos are there.
Remove the old volumes
Wait until you have used the server for some days and made a backup of the new folder. Then the old volumes only take space. This command deletes them for good:
for v in postgres_data seaweedfs_master seaweedfs_volume seaweedfs_filer redis_data api_storage caddy_data caddy_config; do
docker volume rm "${PROJECT}_$v"
doneSet PROJECT again first, as in step 1, if you use a new shell.
Back up the folder
All data of the server is now in one folder. Stop the server, copy the folder with cp -a, and start the server again. Save .env with the copy, because it holds COMPOSE_FILE and DATA_LOCATION. The exact commands, and how to restore, are in Backup and restore.
When it does not work
- A log shows
permission deniedfor a folder underDATA_LOCATION. The file system does not keep owners, or a copy did not usecp -a. See the warning in The folder layout. - The server starts empty after the move.
DATA_LOCATIONin.envand the folder of the copy differ. Compare them, then rundocker compose downanddocker compose up -d. docker runsaysincludes invalid characters for a local volume name.DATA_LOCATIONis not a full path. Use a path that starts with/.
More problems and fixes are in Troubleshooting.