Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用docker部署时提示内存不足 #2069

Open
Chang-Tao opened this issue Apr 13, 2024 · 2 comments
Open

使用docker部署时提示内存不足 #2069

Chang-Tao opened this issue Apr 13, 2024 · 2 comments

Comments

@Chang-Tao
Copy link

部署遇到的问题

    1. /cloudreve/conf.ini 是一个路径而不是文件
    1. 初始化数据库时内存不足
尝试解决
    1. 提前在./cloudreve路径下创建conf.ini文件, 不确定会有什么问题
    1. 1完成后,不再提示错误,但是报告初始化数据库库内存不足, 换了三个Ubuntu虚拟机都是这个问题.

1./cloudreve/conf.ini 是一个路径而不是文件

    cloudreve  |    ___ _                 _                    
    cloudreve  |   / __\ | ___  _   _  __| |_ __ _____   _____ 
    cloudreve  |  / /  | |/ _ \| | | |/ _  | '__/ _ \ \ / / _ \
    cloudreve  | / /___| | (_) | |_| | (_| | | |  __/\ V /  __/
    cloudreve  | \____/|_|\___/ \__,_|\__,_|_|  \___| \_/ \___|
    cloudreve  | 
    cloudreve  |    V3.8.3  Commit #88409cc  Pro=false
    cloudreve  | ================================================
    cloudreve  | 
    cloudreve  | [Panic]   2024-04-13 12:08:46 Failed to parse config file "/cloudreve/conf.ini": BOM: read /cloudreve/conf.ini: is a directory
    cloudreve  | panic: Failed to parse config file "/cloudreve/conf.ini": BOM: read /cloudreve/conf.ini: is a directory
    cloudreve  | 
    cloudreve  | goroutine 1 [running]:
    cloudreve  | github.com/cloudreve/Cloudreve/v3/pkg/util.(*Logger).Panic(0xc00003c2c0, {0x1565ee1?, 0x0?}, {0xc0002258c8?, 0x0?, 0x0?})
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/pkg/util/logger.go:74 +0x94
    cloudreve  | github.com/cloudreve/Cloudreve/v3/pkg/conf.Init({0xc00028ef60, 0x13})
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/pkg/conf/conf.go:108 +0x5cf
    cloudreve  | github.com/cloudreve/Cloudreve/v3/bootstrap.Init({0xc00028ef60, 0x13}, {0x1a6b960, 0xc000011200})
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:24 +0x65
    cloudreve  | main.init.0()
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/main.go:42 +0x1ca
    cloudreve exited with code 2

Failed to connect to database

    cloudreve  | 
    cloudreve  |    ___ _                 _                    
    cloudreve  |   / __\ | ___  _   _  __| |_ __ _____   _____ 
    cloudreve  |  / /  | |/ _ \| | | |/ _  | '__/ _ \ \ / / _ \
    cloudreve  | / /___| | (_) | |_| | (_| | | |  __/\ V /  __/
    cloudreve  | \____/|_|\___/ \__,_|\__,_|_|  \___| \_/ \___|
    cloudreve  | 
    cloudreve  |    V3.8.3  Commit #88409cc  Pro=false
    cloudreve  | ================================================
    cloudreve  | 
    cloudreve  | [Info]    2024-04-13 12:30:36 Initializing database connection...
    cloudreve  | [Panic]   2024-04-13 12:30:36 Failed to connect to database: unable to open database file: out of memory (14)
    cloudreve  | panic: Failed to connect to database: unable to open database file: out of memory (14)
    cloudreve  | 
    cloudreve  | goroutine 1 [running]:
    cloudreve  | github.com/cloudreve/Cloudreve/v3/pkg/util.(*Logger).Panic(0xc0003e9090, {0x1564120?, 0xc00044bb98?}, {0xc00044bb98?, 0x14565c0?, 0x440b00?})
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/pkg/util/logger.go:74 +0x94
    cloudreve  | github.com/cloudreve/Cloudreve/v3/models.Init()
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/models/init.go:76 +0x70a
    cloudreve  | github.com/cloudreve/Cloudreve/v3/bootstrap.Init.func5()
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:61 +0x17
    cloudreve  | github.com/cloudreve/Cloudreve/v3/bootstrap.Init({0xc0002d4cd8, 0x13}, {0x1a6b960, 0xc000010120})
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:128 +0x29b
    cloudreve  | main.init.0()
    cloudreve  |    /Users/aaronliu/Projects/Cloudreve/main.go:42 +0x1ca
    cloudreve exited with code 2
    ^CGracefully stopping... (press Ctrl+C again to force)
    cloudreve exited with code 0

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'docker-compose up'
docker-compose.yaml
    version: "3.8"
    services:
      redis:
        container_name: redis
        image: bitnami/redis:latest
        restart: unless-stopped
        environment:
          - ALLOW_EMPTY_PASSWORD=yes
        volumes:
          - redis_data:/bitnami/redis/data
    
      cloudreve:
        container_name: cloudreve
        image: cloudreve/cloudreve:latest
        restart: unless-stopped
        ports:
          - "5212:5212"
        volumes:
          - temp_data:/data
          - ./cloudreve/uploads:/cloudreve/uploads
          - ./cloudreve/conf.ini:/cloudreve/conf.ini
          - ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db
          - ./cloudreve/avatar:/cloudreve/avatar
        depends_on:
          - aria2
    
      aria2:
        container_name: aria2
        image: p3terx/aria2-pro # third party image, please keep notice what you are doing
        restart: unless-stopped
        environment:
          - RPC_SECRET=cloudreve # aria rpc token, customize your own
          - RPC_PORT=6800
        volumes:
          - ./aria2/config:/config
          - temp_data:/data
    volumes:
      redis_data:
        driver: local
      temp_data:
        driver: local
        driver_opts:
          type: none
          device: $PWD/data
          o: bind
@Chang-Tao
Copy link
Author

1

我注意到挂在卷中还有一个cloudreve.db, 好像是也被认成了路径,我删除了/cloudreve/cloudreve.db这个路径,创建了一个cloudreve.db空文件,现在所有容器都启动了, 可以登录, 我依然不知道这样做会有什么问题

卷参数

按照下面的参数,没有改动, 启动容器时,中间的两个文件,会被创建成一个同名的文件夹,导致容器运行出错。
volumes:
- temp_data:/data
- ./cloudreve/uploads:/cloudreve/uploads
- ./cloudreve/conf.ini:/cloudreve/conf.ini
- ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db
- ./cloudreve/avatar:/cloudreve/avatar

@sisuad
Copy link

sisuad commented May 22, 2024

Same issue as the original poster.

Problem cause:
In the docker-compose.yml file for the Cloudreve image, the mounted volumes:

  • ./cloudreve/conf.ini:/cloudreve/conf.ini
  • ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db

will create two folders conf.ini and cloudreve.db, but actually two files are needed. The solution is to delete these two folders and create files with the same names in the corresponding directories.

Solution steps are as follows:

step 1. Use the default docker-compose file to start, the image on port 5212 will keep restarting, and you can see the error log inside the container.

ERROR: for aria2 Cannot start service aria2: error while mounting volume '/var/lib/docker/volumes/cloudreve_temp_data/_data': failed to mount local volume: mount /media/zt/partition2/projects/Cloudreve/data:/var/lib/docker/volumes/cloudreve_temp_data/_data, flags: 0x1000: no such file or directory
ERROR: Encountered errors while bringing up the project.

step 2. Use docker-compose down to stop all containers.

step 3. Delete the ./cloudreve/conf.ini folder and create a new conf.ini file using touch conf.ini.

step 4. Delete the /cloudreve/cloudreve.db folder and create a new cloudreve.db file using touch cloudreve.db.

step 5. Restart using docker-compose up -d.

If you only execute step 3 and not step 4, you will encounter an out-of-memory error:

[Info] 2024-05-22 17:37:43 Initializing database connection...
[Panic] 2024-05-22 17:37:43 Failed to connect to database: unable to open database file: out of memory (14)
panic: Failed to connect to database: unable to open database file: out of memory (14)
goroutine 1 [running]:
github.com/cloudreve/Cloudreve/v3/pkg/util.(*Logger).Panic(0xc000798600, {0x1564120?, 0xc00028fb98?}, {0xc00028fb98?, 0x14565c0?, 0x440b00?})
/Users/aaronliu/Projects/Cloudreve/pkg/util/logger.go:74 +0x94
github.com/cloudreve/Cloudreve/v3/models.Init()
/Users/aaronliu/Projects/Cloudreve/models/init.go:76 +0x70a
github.com/cloudreve/Cloudreve/v3/bootstrap.Init.func5()
/Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:61 +0x17
github.com/cloudreve/Cloudreve/v3/bootstrap.Init({0xc000546780, 0x13}, {0x1a6b960, 0xc0004a60f0})
/Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:128 +0x29b
main.init.0()
/Users/aaronliu/Projects/Cloudreve/main.go:42 +0x1ca


和楼主一样的问题

问题原因:
docker-compose.yml的cloudreve镜像挂载卷中,

  • ./cloudreve/conf.ini:/cloudreve/conf.ini
  • ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db
    会创建两个文件夹conf.inicloudreve.db,实际是需要两个文件,解决思路是删除这两个文件夹,同时在对应的目录下创建同名文件

解决方式如下:

step 1. 使用默认的docker-compose文件启动,5212端口镜像会一直重启,进入容器内可以看到报错日志

ERROR: for aria2 Cannot start service aria2: error while mounting volume '/var/lib/docker/volumes/cloudreve_temp_data/_data': failed to mount local volume: mount /media/zt/partition2/projects/Cloudreve/data:/var/lib/docker/volumes/cloudreve_temp_data/_data, flags: 0x1000: no such file or directory
ERROR: Encountered errors while bringing up the project.

step2.使用docker-compose down退出全部容器

step3.删除./cloudreve/conf.ini文件夹,新建conf.ini文件touch conf.ini

step4.删除/cloudreve/cloudreve.db文件夹,新建cloudreve.db文件touch cloudreve.db

step5.重新启动docker-compose up -d

如果只执行step3,不执行step4,会出现内存不足报错:

[Info] 2024-05-22 17:37:43 Initializing database connection...
[Panic] 2024-05-22 17:37:43 Failed to connect to database: unable to open database file: out of memory (14)
panic: Failed to connect to database: unable to open database file: out of memory (14)
goroutine 1 [running]:
github.com/cloudreve/Cloudreve/v3/pkg/util.(*Logger).Panic(0xc000798600, {0x1564120?, 0xc00028fb98?}, {0xc00028fb98?, 0x14565c0?, 0x440b00?})
/Users/aaronliu/Projects/Cloudreve/pkg/util/logger.go:74 +0x94
github.com/cloudreve/Cloudreve/v3/models.Init()
/Users/aaronliu/Projects/Cloudreve/models/init.go:76 +0x70a
github.com/cloudreve/Cloudreve/v3/bootstrap.Init.func5()
/Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:61 +0x17
github.com/cloudreve/Cloudreve/v3/bootstrap.Init({0xc000546780, 0x13}, {0x1a6b960, 0xc0004a60f0})
/Users/aaronliu/Projects/Cloudreve/bootstrap/init.go:128 +0x29b
main.init.0()
/Users/aaronliu/Projects/Cloudreve/main.go:42 +0x1ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants