• 本帖最后由 颠峰布衣飘 于 2018-10-25 00:30 编辑 *

正确方法 最后只放一条CMD
多条命令这样写 CMD haproxy -f /etc/haproxy/haproxy.cfg && php-fpm & \
nginx -g "daemon off;"

加个命令连接符而以 尼玛扯到天上去了 && 连接符啊
==================================下面的是请教的问题===================

  • FROM php:alpine
  • WORKDIR /var/www/html
  • COPY / /var/www/html/
  • RUN apk add --no-cache nginx \
  • && mkdir /run/nginx \
  • && chown -R www-data:www-data cache/ config/ \
  • && mv default.conf /etc/nginx/conf.d \
  • && mv php.ini /usr/local/etc/php \
  • && rm -rf /etc/haproxy/haproxy.cfg \
  • && mv haproxy.cfg /etc/haproxy
  • CMD ["haproxy", "-f", "/etc/haproxy/haproxy.cfg"]
  • EXPOSE 80 6800
  • # Persistent config file and cache
  • VOLUME [ "/var/www/html/config", "/var/www/html/cache" ]
  • - CMD php-fpm & \
  • nginx -g "daemon off;"复制代码

怎么haproxy 这个服务启动不起来呢。。 配制文件都没问题
进容器 docker run -it test /bin/sh 之后执行 haproxy -f /etc/haproxy/haproxy.cfg 才能用

我网上找了好多写法都没法子通过- RUN set -x \

  • haproxy -f /etc/haproxy/haproxy.cfg 失败
  • - ENTRYPOINT ["/docker-entrypoint.sh"] 也失败
  • - 复制代码

单独写个sh脚本copy进容器里 sh ss.sh也可以成功

现在就想怎么在dockerfile里处理 写好
运行docker run -d -p 1:1 test 这样 haproxy就能启动