DOCKERFILE:运行多个CMD.(启动NGINX和PHP)

Nic*_*ury 6 php nginx docker dockerfile

我有一个dockerfile设置NGINX,PHP,添加一个Wordpress存储库.我想在启动时启动PHP和NGINX.但是,我没有这样做.我尝试在CMD数组中添加两个命令,我也尝试将它们放在shell文件中并启动shell文件.没有任何效果.下面是我的Dockerfile

FROM ubuntu:16.04

WORKDIR /opt/

#Install nginx
RUN apt-get update
RUN apt-get install -y nginx=1.10.* php7.0 php7.0-fpm php7.0-mysql

#Add the customized NGINX configuration
RUN rm -f /etc/nginx/nginx.conf
RUN rm -f /etc/nginx/sites-enabled/*

COPY nginx/nginx.conf /etc/nginx/
COPY nginx/site.conf /etc/nginx/sites-enabled

#Copy the certificates
RUN mkdir -p /etc/pki/nginx
COPY nginx/certs/* /etc/pki/nginx/
RUN rm -f /etc/pki/nginx/placeholder

#Copy the build to its destination on the server
RUN mkdir -p /mnt/wordpress-blog/
COPY . /mnt/wordpress-blog/

#COPY wp-config.php
COPY nginx/wp-config.php /mnt/wordpress-blog/

#The command to run the container
CMD ["/bin/bash", "-c", "service php7.0-fpm start", "service nginx start"]
Run Code Online (Sandbox Code Playgroud)

我试图将命令放在CMD中的shell文件中,然后在CMD命令中运行shell文件.它仍然无法正常工作.我错过了什么?

atl*_*ine 5

启动文件

#!/bin/bash

/usr/sbin/service php7.0-fpm start
/usr/sbin/service nginx start
tail -f /dev/null
Run Code Online (Sandbox Code Playgroud)

文件

COPY ["start.sh", "/root/start.sh"]
WORKDIR /root
CMD ["./start.sh"]
Run Code Online (Sandbox Code Playgroud)

有了这个,您可以将更复杂的逻辑放入start.sh.