提升docker集装箱内的风帆

我知道有很多例子(实际上只有几个例子),我研究了一些,并试图将它们应用到我的案例中,但是当我尝试提起容器时( docker-compose up ),我最终得到了更多或每次更less的相同的错误。

我的文件夹结构是:

 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 ,但我得到:

在这里输入图像说明

当然,我尝试了不同的Dockerfileconfiguration,然后用不同的命令( node appsails liftnpm start等),但不断结束了相同的错误。 有任何想法吗?

通过使用command: node app您正在覆盖命令 CMD ["/app/app.js", "--no-daemon"] ,因此将不起作用。 WORKDIR /app 将创build一个应用程序文件夹,所以你不必RUN mkdir /app 。 最重要的是你必须RUN cd /app; npm i RUN cd /app; npm iCMD ["/app/app.js", "--no-daemon"]之前CMD ["/app/app.js", "--no-daemon"] 。 在启动应用程序之前,必须先安装NPM依赖项。