Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with full RAG and AI Agent capabilities.
https://useanything.com
MIT License
15.35k stars 1.6k forks source link

[BUG]: Container cashing with docker run command provided in the documentation #1402

Closed clipod closed 2 weeks ago

clipod commented 2 weeks ago

How are you running AnythingLLM?

Docker (local)

What happened?

I am trying to run anythingllm in local docker. My docker is installed on a Debian instance. I am running the command given in the documentation as root(unfortunately I dont have a choice).

export STORAGE_LOCATION=/tmp/anything-llm/docker && mkdir -p $STORAGE_LOCATION && touch "$STORAGE_LOCATION/.env" && docker run -d -p 3001:3001 --cap-add SYS_ADMIN -v ${STORAGE_LOCATION}:/app/server/storage -v ${STORAGE_LOCATION}/.env:/app/server/.env -e STORAGE_DIR="/app/server/storage" mintplexlabs/anythingllm

I am getting the below error,

Collector hot directory and tmp storage wiped!
Document processor app listening on port 8888
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 197ms
Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db"
Error: Schema engine error:
SQLite database error
unable to open database file: ../storage/anythingllm.db

Not sure what I am doing wrong here.

Are there known steps to reproduce?

No response

hmazomba commented 2 weeks ago

I also get the same error when running this command on Arch linux.

Command: export STORAGE_LOCATION=$HOME/anythingllm && \ mkdir -p $STORAGE_LOCATION && \ touch "$STORAGE_LOCATION/.env" && \ docker run -d -p 3001:3001 \ --cap-add SYS_ADMIN \ -v ${STORAGE_LOCATION}:/app/server/storage \ -v ${STORAGE_LOCATION}/.env:/app/server/.env \ -e STORAGE_DIR="/app/server/storage" \ mintplexlabs/anythingllm

timothycarambat commented 2 weeks ago

/tmp/ is a non-writable directory by the docker user. This typically works better on *inx system when you either give the docker-user the permission to write at those top level folders or just run the container in the $HOME of the user running the container.

hmazomba commented 2 weeks ago

Ok but bruv that doesn't help because I am using my $HOME. Literally ran it inside my $HOME directory, still getting an error about anythingllm.db

timothycarambat commented 2 weeks ago

Sorry i didn't see the second comment for some reason, clearly you did that

unable to open database file: ../storage/anythingllm.db

Would indicate that there is no file anythingllm.db in $HOME/anythingllm - however, the container should create it automatically. If it is not, that would prevent docker from booting or is the file is non-readable/editable

-v ${STORAGE_LOCATION}:/app/server/storage

binds $HOME/anythingllm in host to /app/server/storage in the container. So we should expect to see anythingllm.db in there

clipod commented 2 weeks ago

Ok, now I got this error. Its the same error in the logs when I tried building using docker-compose too.

My command:

export STORAGE_LOCATION=$HOME/anythingllm && mkdir -p $STORAGE_LOCATION && touch "$STORAGE_LOCATION/anythingllm.db" &&touch "$STORAGE_LOCATION/.env" && docker run -d -p 3001:3001 --cap-add SYS_ADMIN -v ${STORAGE_LOCATION}:/app/server/storage -v ${STORAGE_LOCATION}/.env:/app/server/.env -e STORAGE_DIR="/app/server/storage" mintplexlabs/anythingllm

Logs:

Collector hot directory and tmp storage wiped!
Document processor app listening on port 8888
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 196ms
Start using Prisma Client in Node.js (See: https://pris.ly/d/client)

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "anythingllm.db" at "file:../storage/anythingllm.db"
20 migrations found in prisma/migrations
Error: SQLite database error
attempt to write a readonly database
   0: sql_schema_connector::sql_migration_persistence::initialize
           with namespaces=None
             at schema-engine/connectors/sql-schema-connector/src/sql_migration_persistence.rs:14
   1: schema_core::state::ApplyMigrations
             at schema-engine/core/src/state.rs:201

Just to be sure I gave all permissions to that file.

root@pve:~/anythingllm# ls -lta
total 8
-rw-r--r--  1 root root    0 May 16 13:06 .env
-rwxrwxrwx  1 root root    0 May 16 12:59 anythingllm.db
drwxr-xr-x  2 root root 4096 May 16 12:59 .
drwx------ 23 root root 4096 May 16 12:57 ..
timothycarambat commented 2 weeks ago

attempt to write a readonly database

So this is where my first comment is more relevant. The file is not writable by whatever user is running the docker container. You can chmod -R $HOME/anythingllm and it'll be writeable by the container now

clipod commented 2 weeks ago

Ah, I was giving write permissions to just the DB file. But once I gave it to the whole folder, the container stood up. Thanks.