简体   繁体   English

Docker云服务因找不到脚本而停止

[英]Docker cloud services stop with script not found

I've been trying to deploy my app with docker cloud stack. 我一直在尝试使用docker cloud stack部署我的应用程序。 I've tested this locally and I've also tested with docker-compose and they worked successfully. 我已经在本地进行了测试,并且还使用了docker-compose进行了测试,并且它们工作成功。

However, when I tried to deploy my docker container from my registry which is in my docker repo with docker cloud stack, it always stops with below code. 但是,当我尝试从我的注册表中部署带有Docker云堆栈的Docker存储库中的Docker容器时,它始终会以下面的代码停止。

[app-1]2018-02-10T06:09:03.316866500Z script not found : /src/dist/index.js

[app-1]2018-02-10T06:09:03.317330400Z Exiting PM2

[app-1]2018-02-10T06:09:03.442521200Z 0 application online, exiting

[app-1]2018-02-10T06:09:03.442686000Z Exiting PM2

I've tried to set src/dist/index.js to dist/index.js and tried many other things and none of them worked for me. 我试图将src/dist/index.jsdist/index.js并尝试了许多其他方法,但没有一个对我有用。

My Dockerfile looks like below. 我的Dockerfile如下所示。

FROM dooboolab/ubuntu-nodejs-ffmpeg-sharp:latest

WORKDIR /src
COPY package*.json ./

# RUN npm install
RUN npm install --only=production

# If you are building your code for production

# Bundle app source
ADD . /src

EXPOSE 3000
CMD ["pm2-docker", "/dist/index.js"]

And my stack file is simple like below. 我的堆栈文件很简单,如下所示。 app: environment: - NODE_ENV=production image: 'my_private_image:latest' ports: - '3000:3000' 应用程序:环境:-NODE_ENV =生产映像:“ my_private_image:最新”端口:-“ 3000:3000”

Again, my_private_image:latest works just fine when I build my container from docker repo in my local machine. 同样,当我从本地计算机中的my_private_image:latest repo构建容器时, my_private_image:latest可以正常工作。

What else can I try more to solve this issue? 我还有什么可以尝试解决这个问题的呢?

I've found out solution. 我找到了解决方案。 This was because locally, it was referencing relative path. 这是因为在本地,它引用的是相对路径。 However, when ran from docker stack, it is running from absolute path so the path was different. 但是,从docker堆栈运行时,它是从绝对路径运行的,因此路径是不同的。

To successfully build from docker-stack, I had to set the absolute path in the image and build it. 为了从docker-stack成功构建,我必须在映像中设置绝对路径并进行构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM