如何使用Dockerfile基于Ubuntu映像启动带有php-fpm的Nginx?

时间:2015-04-26 09:34:35

标签: php ubuntu nginx docker dockerfile

我有Dockerfile一些命令:

FROM ubuntu
RUN apt-get install -y nginx php5 php5-fpm
ADD . /code

当我运行docker build .命令时,我得到下一个错误:

E: Package 'php5-fpm' has no installation candidate
INFO[0006] The command [/bin/sh -c apt-get install nginx php5 php5-fpm] returned a non-zero code: 100 

如何根据Nginx图片php-fpm启动Ubuntu

1 个答案:

答案 0 :(得分:1)

NGiNX可以看到更多complete example here

# Install Nginx.
RUN \
  add-apt-repository -y ppa:nginx/stable && \
  apt-get update && \
  apt-get install -y nginx && \
  rm -rf /var/lib/apt/lists/* && \
  echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
  chown -R www-data:www-data /var/lib/nginx

对于php-fpm,您有this example

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys E5267A6C; \
    echo 'deb http://ppa.launchpad.net/ondrej/php5/ubuntu trusty main' > /etc/apt/sources.list.d/ondrej-php5-trusty.list; \
    apt-get update ; \
    apt-get -y install php5-fpm php5-mysql php-apc php5-imagick php5-imap php5-mcrypt php5-curl php5-cli php5-gd php5-pgsql php5-sqlite php5-common php-pear curl php5-json php5-redis redis-server memcached php5-memcache ; \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

在这两种情况下,请注意使用: