docker - 如何在 docker 中安装 nginx 1.14.X?

标签 docker nginx

# 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: Version '1.4.*' for 'nginx' was not found.

如何以这种方式在 docker 中安装特定版本的 nginx?

最佳答案

正如@larsks Ubuntu 16.04 所指出的仅支持 nginx 到版本 1.10.3
Official wiki更多细节

因此,最好/安全的选择是将您的基本操作系统移至 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

关于docker - 如何在 docker 中安装 nginx 1.14.X?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53694124/

相关文章:

node.js - docker webpack编译文件运行时丢失

php - 从 Docker 容器使用本地主机连接到 MariaDB

php - nginx 和 php-fpm 套接字所有者

nginx - 始终为 'proxy_pass' 并且在以 'auth_basic' 开头的请求上需要 '/admin' 。如何编写nginx配置?

amazon-web-services - 将Docker容器部署到AWS时,是否还需要部署自己的反向代理?

namespaces - 在 Docker 中共享命名空间

bash - 在分离模式下运行docker时设置环境变量

docker - 如何在同一个docker容器或dyno中运行2个进程?

macos - nginx docker容器上的连接被拒绝

ssl - 没有为 "ssl_certificate"指令定义 "listen ... ssl"