当用不同的用户运行容器时,Docker无法在构build中运行
我不知道为什么节点应用程序不运行的具体情况。 基本上我在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:
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
的状态,它停止。
这里是回购,但是,start.bash和dockerfile是不同的,因为我没有提交最新的,因为两者都不工作:
JoeyHipolito /鬼
我设法使它工作,没有错误在start bash
文件,也没有在Dockerfile
,只是我失败了再次build立图像。
这就是说,你可以在我的仓库中签出最终的Dockerfile
和start.bash
文件:
Ghost-blog__Docker(https://github.com/joeyhipolito/ghost)
在我写这个答案的时候,你可以在feature-branch feature/dockerize
看到它。