docker / genai-stack

Langchain + Docker + Neo4j + Ollama
Creative Commons Zero v1.0 Universal
4.07k stars 886 forks source link

/data folder permission issue when running on Linux #134

Open fantasy-fish opened 9 months ago

fantasy-fish commented 9 months ago

OS version: Ubuntu 20.04/22.04 on Azure, no gpu Command I use: docker compose --profile linux up. Also set OLLAMA_BASE_URL=http://llm:11434 in .env Got the error below

WARN[0000] The "LANGCHAIN_PROJECT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_ACCESS_KEY_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_SECRET_ACCESS_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_DEFAULT_REGION" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_PROJECT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_ACCESS_KEY_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_SECRET_ACCESS_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_DEFAULT_REGION" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_PROJECT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_ACCESS_KEY_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_SECRET_ACCESS_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_DEFAULT_REGION" variable is not set. Defaulting to a blank string. 
WARN[0000] The "OPENAI_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GOOGLE_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_PROJECT" variable is not set. Defaulting to a blank string. 
WARN[0000] The "LANGCHAIN_API_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_ACCESS_KEY_ID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_SECRET_ACCESS_KEY" variable is not set. Defaulting to a blank string. 
WARN[0000] The "AWS_DEFAULT_REGION" variable is not set. Defaulting to a blank string. 
[+] Running 3/0
 ✔ Container genai-stack-pull-model-1  Created                                                                                                    0.0s 
 ✔ Container genai-stack-llm-1         Running                                                                                                    0.0s 
 ✔ Container genai-stack-database-1    Created                                                                                                    0.0s 
Attaching to api-1, bot-1, database-1, front-end-1, llm-1, loader-1, pdf_bot-1, pull-model-1
pull-model-1  | pulling ollama model llama2 using http://llm:11434
llm-1         | [GIN] 2024/02/24 - 09:54:52 | 200 |        31.6µs |      172.18.0.4 | HEAD     "/"
llm-1         | [GIN] 2024/02/24 - 09:54:52 | 200 |     595.703µs |      172.18.0.4 | POST     "/api/show"
database-1    | 
database-1    | Folder /data is not accessible for user: 7474 or group 7474. This is commonly a file permissions issue on the mounted folder.
database-1    | 
database-1    | Hints to solve the issue:
database-1    | 1) Make sure the folder exists before mounting it. Docker will create the folder using root permissions before starting the Neo4j container. The root permissions disallow Neo4j from writing to the mounted folder.
database-1    | 2) Pass the folder owner's user ID and group ID to docker run, so that docker runs as that user.
database-1    | If the folder is owned by the current user, this can be done by adding this flag to your docker run command:
database-1    |   --user=$(id -u):$(id -g)
database-1    |        
pull-model-1 exited with code 0
database-1 exited with code 1
dependency failed to start: container genai-stack-database-1 exited (1)

Methods I've used:

  1. set --user=$(id -u):$(id -g) as suggested
  2. change the permission in the /data folder
  3. set the user ID and group ID in docker-compose.yml
ampherion commented 9 months ago

I am experiencing the same. Using Ubuntu 22.04.4

database-1 | database-1 | Folder /data is not accessible for user: 7474 or group 7474. This is commonly a file permissions issue on the mounted folder. database-1 | database-1 | Hints to solve the issue: database-1 | 1) Make sure the folder exists before mounting it. Docker will create the folder using root permissions before starting the Neo4j container. The root permissions disallow Neo4j from writing to the mounted folder. database-1 | 2) Pass the folder owner's user ID and group ID to docker run, so that docker runs as that user. database-1 | If the folder is owned by the current user, this can be done by adding this flag to your docker run command: database-1 | --user=$(id -u):$(id -g) database-1 |

I have attempted:

Edit: I tried to build the docker environment on Windows 10 and had the same issue. Using: 'docker compose up' database-1 | database-1 | Folder /data is not accessible for user: 7474 or group 7474. This is commonly a file permissions issue on the mounted folder. database-1 | database-1 | Hints to solve the issue: database-1 | 1) Make sure the folder exists before mounting it. Docker will create the folder using root permissions before starting the Neo4j container. The root permissions disallow Neo4j from writing to the mounted folder. database-1 | 2) Pass the folder owner's user ID and group ID to docker run, so that docker runs as that user. database-1 | If the folder is owned by the current user, this can be done by adding this flag to your docker run command: database-1 | --user=$(id -u):$(id -g) database-1 | pull-model-1 | pulling ollama model llama2 using http://host.docker.internal:11434

mingwu2333 commented 8 months ago
  1. set the user ID and group ID in docker-compose.yml database: user: ${USER_ID}:${GROUP_ID}
  2. add env variables when docker compose USER_ID=$(id -u) GROUP_ID=$(id -g) docker compose...
ATidiane commented 8 months ago

Replace neo4j:neo4j under the database tag in docker-compose.yml by what @mingwu2333 suggested

database: user: ${USER_ID}:${GROUP_ID}

This should do the trick.

gontxomde commented 8 months ago

I am having the same issue on macOS

I create the folder with my user (uid 501 and guid 20) locally. The output of ls -lnis:

drwxr-xr-x   2 501  20     64 Mar 10 14:52 data

I run the docker compose and I get:

database-1    | Folder /data is not accessible for user: 501 or group 20. This is commonly a file permissions issue on the mounted folder.
database-1    |
database-1    | Hints to solve the issue:
database-1    | 1) Make sure the folder exists before mounting it. Docker will create the folder using root permissions before starting the Neo4j container. The root permissions disallow Neo4j from writing to the mounted folder.
database-1    | 2) Pass the folder owner's user ID and group ID to docker run, so that docker runs as that user.
database-1    | If the folder is owned by the current user, this can be done by adding this flag to your docker run command:
database-1    |   --user=$(id -u):$(id -g)
hsiehgeoVA commented 8 months ago

Also had the same problem on Ubuntu 22.04 running in WSL on Windows 11 PRO host. Then implemented three changes: (a) chown /home/casev/../genai-stack/data directory to casev for userID and groupID. (2) added to /home/casev/.profile two statements: export USER_ID=$(id -u) and export GROUP_ID=$(id -g). (3) modified docker-compose.yml to set database: user: ${USER_ID}:${GROUP_ID}. Next, run docker compose --profile linux up again. This time, the /data file error did not appear, and installed progress forward. However, it still stopped with an error message: dependency failed to start: container genai-stack-api-1 is unhealthy. Even after shutdown and restart, docker compose seemed to be stuck for more than an error while displaying: INFO: 127.0.0.1:xxxxxx - "GET / HTTP/1.1" 200 OK with different port numbers.

What might be the problems? And how to fix them? Thanks.