如何使用 Dockerfile 基于 Ubuntu 图像以 php-fpm 启动 Nginx?

How can I start Nginx with php-fpm based on Ubuntu image using 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 

如何根据 Ubuntu 图片开始 Nginxphp-fpm

您可以看到更多 complete example here NGiNX:

# 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/*

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