我正在尝试从 docker 执行
anything-llm
,并且我正在尝试创建一个 docker-compose.yml
文件,因为我希望它执行超过 1 个容器。
在 anything.llm 的存储库中,它展示了如何从 docker 执行,并且对我来说效果很好。
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
但是就像之前所说的那样,我希望它创建一个
docker-compose.yml
文件来仅用一个文件执行多个容器。这是我的docker-compose.yml
代码:
services:
anythingllm:
image: mintplexlabs/anythingllm
ports:
- "3001:3001"
cap_add:
- SYS_ADMIN
volumes:
- ${STORAGE_LOCATION}:/app/server/storage
- ${STORAGE_LOCATION}/.env:/app/server/.env
environment:
- STORAGE_DIR=/app/server/storage
command: /bin/sh -c "mkdir -p $STORAGE_LOCATION && touch \"$STORAGE_LOCATION/.env\" && npm start"
它下载图像,创建容器,还创建
STORAGE_LOCATION
目录和 .env
文件。但是当要启动容器时我收到以下错误:
container init: error mounting "/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-22.04/..."
当然会返回错误,因为在
/run/
内部我没有desktop
目录。
我正在尝试从 docker 执行
anything-llm
,并且我正在尝试创建一个 docker-compose.yml
文件,因为我希望它执行超过 1 个容器。
在 anything.llm 的存储库中,它展示了如何从 docker 执行,并且对我来说效果很好。
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
但是就像之前所说的那样,我希望它创建一个
docker-compose.yml
文件来仅用一个文件执行多个容器。这是我的docker-compose.yml
代码:
services:
anythingllm:
image: mintplexlabs/anythingllm
ports:
- "3001:3001"
cap_add:
- SYS_ADMIN
volumes:
- ${STORAGE_LOCATION}:/app/server/storage
- ${STORAGE_LOCATION}/.env:/app/server/.env
environment:
- STORAGE_DIR=/app/server/storage
command: /bin/sh -c "mkdir -p $STORAGE_LOCATION && touch \"$STORAGE_LOCATION/.env\" && npm start"
它下载图像,创建容器,还创建
STORAGE_LOCATION
目录和 .env
文件。但是当要启动容器时我收到以下错误:
container init: error mounting "/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-22.04/..."
当然会返回错误,因为在
/run/
内部我没有desktop
目录。
我发现了一些事情:
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
然后停止容器并执行
docker-compose.yml
文件,启动容器时不会出现任何错误。
docker-compose.yml
中的变量替换为如下目录:/home/user/anythingllm
,但在第一次执行时仍然出现错误。我需要对
docker-compose.yml
文件进行哪些更改才能在不从终端执行原始命令的情况下正常工作?
问题出现在
docker-compose.yml
文件的最后一行。
由于某种原因,
touch \"$STORAGE_LOCATION/.env\"
没有创建.env
文件,而是创建了.env
文件夹。所以我决定手动创建它,现在正确创建并执行它。