出于学习目的,我创建了这个Dockerfile:
FROM ubuntu:16.10
RUN useradd -m --password=node node && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y curl && \
apt-get install -y openssl && \
apt-get install -y nginx && \
apt-get -qy autoremove
COPY . /home/node/xxx.com
RUN rm /etc/nginx/sites-enabled/default && \
cd /etc/nginx/sites-enabled && \
ln -s /home/node/xxx.com/xxx.nginx.conf default
WORKDIR /home/node
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \
apt-get install -y nodejs
RUN curl -L https://get.rvm.io | bash -s stable && \
/bin/bash -l -c "rvm requirements" && \
/bin/bash -l -c "rvm install 2.0" && \
/bin/bash -l -c "gem update --system" && \
/bin/bash -l -c "gem install bundler --no-ri --no-rdoc" && \
/bin/bash -l -c "gem install compass --no-ri --no-rdoc" && \
/bin/bash -l -c "gem install bootstrap -v 4.0.0.alpha6 --no-ri --no-rdoc"
RUN chown -R node:node /home/node/xxx.com
USER node
WORKDIR /home/node/xxx.com
ENTRYPOINT ["/bin/bash", "-l", "-c", "./entry.sh"]entry.sh
service nginx start
npm install
npm run watch &
compass watch在我的笔记本电脑(Ubuntu 16.04)上开始工作。运行容器(使用-p 8000:80)一切正常,但在我的工作站(Ubuntu14.10)上,nginx不能在容器内启动。如果我先运行docker exec -it -u root <cid> /bin/bash,然后运行service nginx start,那么一切都在运行。
如何在不使用额外命令的情况下做到这一点?为什么它可以在我的笔记本电脑上运行,而不能在我的工作站上运行?
顺便说一句:
工作站$ docker version
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:10:36 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:10:36 2017
OS/Arch: linux/amd64
Experimental: false笔记本电脑:
Client:
Version: 1.12.6
API version: 1.24
Go version: go1.6.2
Git commit: 78d1802
Built: Tue Jan 31 23:35:14 2017
OS/Arch: linux/amd64
Server:
Version: 1.12.6
API version: 1.24
Go version: go1.6.2
Git commit: 78d1802
Built: Tue Jan 31 23:35:14 2017
OS/Arch: linux/amd64发布于 2017-05-24 15:25:40
也许您应该将nginx.sh文件复制到容器中,并使用shell脚本作为入口点启动容器?
来自ubuntu:16.10
//添加启动脚本到临时添加运行-nginx.sh /tmp/ RUN useradd -m --password=节点节点&& \ apt-get update && \ apt-get update -y && \ apt-get install -y curl && \ apt-get install -y openssl && \ apt-get install -y nginx && \ apt-get -qy autoremove COPY。/home/node/xxx.com运行rm /etc/nginx/sites-enabled/default && \ cd /etc/nginx/sites-enabled && \ ln -s /home/node/xxx.com/xxx.nginx.conf default WORKDIR /home/node运行curl -sL https://deb.nodesource.com/setup_7.x | bash - && \ apt-get安装-y nodejs运行curl -l https://get.rvm.io | bash -s稳定&\ /bin/bash -L -c "rvm要求“&&\ /bin/bash -l -c "rvm install 2.0“&& \ /bin/bash -l -c "gem update --system”&& \ /bin/bash -l -c "gem安装捆绑包--no-ri --no-rdoc“&& \ /bin/bash -l -c "gem安装指南针--no-ri --no-rdoc”&& \ /bin/bash -l -c "gem安装引导-v 4.0.0.alpha6 --no-ri --no-rdoc“//复制到主页并设置为可执行运行mv /tmp/ RUN -nginx.sh / && chmod +x / RUN -nginx.sh运行chown -R节点: node / home /node/xxx.com用户节点WORKDIR /home/node/xxx.com入口点"/run-nginx.sh"
https://stackoverflow.com/questions/44151116
复制相似问题