COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

supervisord.conf

[supervisord]
nodaemon=true

[program:sshd]
command=/usr/sbin/sshd -D

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"

[program:php5-fpm]
command=/usr/sbin/php5-fpm --nodaemonize --fpm-config /etc/php5/fpm/php-fpm.conf

[program:php-fpm7.0]
command=/usr/sbin/php-fpm7.0 --nodaemonize --fpm-config=/etc/php/7.0/fpm/php-fpm.conf

[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"

[program:mysql]
command=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe
autorestart=true

entrypoint.sh

#!/bin/bash

set -e

chown -R www-data:www-data /var/www/html

# init mysql db if necessary
if [ ! -d /var/lib/mysql/mysql ];then
  mysql_install_db
fi

chown -R mysql:mysql /var/lib/mysql

exec /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf

启动命令

随Docker容器启动的命令貌似也不少,例如可以是上面的execENTRYPOINT,也可以是CMD

EXPOSE 22 80 443
CMD ["/usr/bin/supervisord"]

或者:

CMD supervisord -c /etc/supervisor.conf

再:

CMD ["/usr/bin/supervisord"]

另外:

EXPOSE 22 80 443
ENTRYPOINT ["/entrypoint.sh"]

玩Docker的时候感觉真是有些头大!