最近在使用docker-compose搭建calibre-web
但是拉取的镜像文件在启动过程中都会提示db无效 ,看网上说是目录权限问题或者无法生成metadata.db
最后发现其实都不对
calibre-web只是一个web支持,它还是需要使用到已有calibre程序的数据库文件【 此应用程序要求您在 /books 位置拥有现有的 calibre 数据库 】
那么知道这个问题以后可以通过初始化metadata.db去解决该问题
使用docker exec -it calibre-web /bin/bash 进入容器目录
cd /config 目录下创建 metadata_generator.sh 文件,文件内容如下:
#!/bin/bash
FILE=/books/metadata.db
PUID=1000
PGID=1000
if test -f "$FILE"; then
echo "$FILE already exists, skipping generation."
else
echo "$FILE does not exists, generating..."
cd /app/calibre/bin
calibredb restore_database --really-do-it --with-library /books
echo "$FILE created, setting permissions..."
chmod a+w $FILE
# this is needed for uploads, you can remove it if you don't want to allow uploads
chown $PUID:$PGID /books
echo "Permissions fixed, use /books as library path"
fi
chmod 755 metadata_generator.sh 赋予文件执行权限
sh metadata_generator.sh
[root@fb82c5f746df config]# sh metadata_generator.sh
/books/metadata.db does not exists, generating...
metadata_generator.sh: line 11: cd: /app/calibre/bin: No such file or directory
Starting restoring preferences and column metadata ... 0%
Cannot restore preferences. Backup file not found. ... 100%
Restoring database succeeded
old database saved as /books/metadata_pre_restore.db
/books/metadata.db created, setting permissions...
Permissions fixed, use /books as library path
之后在books文件夹中生成了我们需要的 metadata.db文件
没有再提示db无效
附上我的docker-compose.yml文件配置
version: '3'
services:
calibre-web:
image: 'ctiself/calibre-web'
container_name: calibre
restart: always
environment:
- TZ=Asia/Shanghai
- PASSWORD=123456
ports:
- '18083:8083'
privileged: true
volumes:
- ./books:/books
- ./config:/config
networks:
default:
ipv4_address: 172.19.0.11
networks:
default:
external:
name: buzhike
~
Comments | NOTHING