# 1. use ubuntu 16.04 as base image
FROM ubuntu:16.04
# defining user root
USER root
# OS update
RUN apt-get update
# Installing PHP and NginX
RUN apt-get install -y nginx=1.4.* php7.0
# Remove the default Nginx configuration file
RUN rm -v /etc/nginx/nginx.conf
# Copy a configuration file from the current directory
ADD nginx.conf /etc/nginx/
ADD web /usr/share/nginx/html/
# Append "daemon off;" to the beginning of the configuration
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Expose ports
EXPOSE 90
# Set the default command to execute
# when creating a new container
CMD service nginx start
答案 0 :(得分:0)
您已将Docker映像基于ubuntu:16.04
。 Ubuntu 16.04发行版不包含nginx 1.14.x;它只有nginx 1.10.3:
$ docker run -it --rm ubuntu:16.04 bash
root@1d780d71ebd5:/# apt update
[...]
root@1d780d71ebd5:/# apt show nginx
Package: nginx
Version: 1.10.3-0ubuntu0.16.04.3
[...]
如果您想要更新版本的nginx,请考虑将映像基于更新的Ubuntu版本,或者从源代码自行构建。例如,Ubuntu 18.04发行版包含nginx 1.14:
$ docker run -it --rm ubuntu:18.04 bash
root@d7ca6d8960f6:/# apt update
[...]
root@d7ca6d8960f6:/# apt show nginx
Package: nginx
Version: 1.14.0-0ubuntu1.2
[...]
答案 1 :(得分:0)
为此的其他选项是,您可以下载tar(源代码)并将其解压缩。 下面是您需要遵循的命令:-
$ wget https://nginx.org/download/nginx-1.14.0.tar.gz
$ tar zxf nginx-1.14.0.tar.gz
$ cd nginx-1.14.0
$ make
$ sudo make install
$ sudo nginx
更多详细信息,请点击此处Nginx- Install doc
答案 2 :(得分:0)
@larsks指出,Ubuntu 16.04
仅在版本1.10.3
之前支持nginx
因此,最好/安全的选择是将基本操作系统移至18.04
或使用nginx 1.10.3
仅供参考,您如何从src安装Nginx。
wget https://nginx.org/download/nginx-1.14.0.tar.gz
tar zxf nginx-1.14.0.tar.gz
cd nginx-1.14.0
make
sudo make install
sudo nginx
更多详细信息here
答案 3 :(得分:0)
FROM ubuntu
ENV NGINX_VERSION 1.14.0-0ubuntu1.2
RUN apt-get update && apt-get -y install nginx=$NGINX_VERSION