# 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
这是我的Dockerfile . 我想安装1.14.2的Nginx但出现错误 .
E:未找到'nginx'版本'1.4 . *' .
如何以这种方式在docker中安装特定版本的nginx .
3 回答
正如@larsks指出
Ubuntu 16.04
仅支持nginx版本1.10.3
Official wiki更详细
所以最好/安全的选择是将您的基本操作系统移动到
18.04
或使用nginx1.10.3
仅供参考如何从src安装Nginx .
更多细节here
您已将您的Docker镜像基于
ubuntu:16.04
. Ubuntu的16.04版本不包括nginx 1.14.x;它只有nginx 1.10.3:如果您想要更新版本的nginx,请考虑将您的图像基于更新的Ubuntu版本,或者自己从源代码构建它 . 例如,Ubuntu的18.04版包含nginx 1.14:
其他选项是你可以下载tar(源代码)并解压缩 . 以下是您需要遵循的命令: -
更多细节可以在这里看到Nginx- Install doc