在使用不同用户运行容器时,Docker无法在构建上运行

时间:2014-09-30 06:38:40

标签: node.js bash docker

我不知道节点应用程序无法运行的具体细节。基本上我在nodejs应用程序中添加了一个dockerfile,这是我的Dockerfile

 FROM node:0.10-onbuild
 RUN mv /usr/src/app /ghost && useradd ghost --home /ghost && \
 cd /ghost
 ENV NODE_ENV production
 VOLUME ["/ghost/content"]
 WORKDIR /ghost
 EXPOSE 2368
 CMD ["bash", "start.bash"]

start.bash看起来像这样:

 #!/bin/bash

 GHOST="/ghost"
 chown -R ghost:ghost /ghost
 su ghost << EOF
 cd "$GHOST"
 NODE_ENV={$NODE_ENV:-production} npm start
 EOF

我通常像这样运行码头:

 docker run --name ghost -d -p 80:2368 user/ghost

有了这个,我无法看到发生了什么,我决定这样运行:

 docker run --name ghost -it -p 80:2368 user/ghost

我得到了这个输出:

 > ghost@0.5.2 start /ghost
 > node index

似乎就像开始一样,但当我检查容器docker ps -a的状态时,它就会停止。

这是repo,但是,start.bash和dockerfile是不同的,因为我没有提交最新的,因为两者都不起作用:

JoeyHipolito/Ghost

1 个答案:

答案 0 :(得分:1)

我设法让它工作,start bash文件和Dockerfile中没有错误,只是我没有再次构建图像​​。

话虽如此,您可以查看我的存储库中的最终Dockerfilestart.bash文件:

Ghost-blog__Docker (https://github.com/joeyhipolito/ghost)

在我写这个答案时,您可以在功能分支feature/dockerize中看到它。