gpt4 book ai didi

docker - 在 Docker 容器内升起风 sails

转载 作者:行者123 更新时间:2023-12-01 14:35:39 24 4
gpt4 key购买 nike

我知道那里有多个示例(实际上只有几个),我研究了一些并尝试将它们应用到我的案例中,但是当我尝试提起容器时(docker-compose up ) 我每次都或多或少地遇到相同的错误。

我的文件夹结构是:

sails-project
--app
----api
----config
----node_modules
----.sailsrc
----app.js
----package.json

--docker-compose.yml
--Dockerfile

docker-compose.yml 文件:

sails:
build: .
ports:
- "8001:80"
links:
- postgres
volumes:
- ./app:/app
environment:
- NODE_ENV=development
command: node app

postgres:
image: postgres:latest
ports:
- "8002:5432"

Dockerfile:

FROM node:0.12.3

RUN mkdir /app

WORKDIR /app

# the dependencies are already installed in the local copy of the project, so
# they will be copied to the container
ADD app /app

CMD ["/app/app.js", "--no-daemon"]

RUN cd /app; npm i

我也尝试过使用 RUN npm i -g sails(在 Dockerfile 中)和 command:sails lift,但我得到:

enter image description here

当然,我尝试了 Dockerfile 的不同配置,然后使用不同的命令(node appsails liftnpm start 等...),但不断以相同的错误结束。有什么想法吗?

最佳答案

通过使用 command: node app,您将覆盖 command CMD ["/app/app.js", "--no-daemon"] 结果将无效。 WORKDIR/app will create an app folder所以你不必 RUN mkdir/app。最重要的是你必须 RUN cd/app; npm iCMD ["/app/app.js", "--no-daemon"] 之前。必须在启动应用程序之前安装 NPM 依赖项。

关于docker - 在 Docker 容器内升起风 sails ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39640488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com