apt-get install -y nginx 更新版本

apt-get install -y nginx with newer version

在 Dockerfile 中:

FROM node:8
RUN apt-get update && apt-get install -y \
  nginx

我想我通过这种方式获得了一个非常旧版本的nginx。如何安装更新版本,例如 1.15.7? 我可以做类似的事情吗:

FROM node:8
RUN apt-get update && apt-get install -y \
  curl \
  # Where to download the nginx source? Pass the download path below
  && curl -sL \
  && apt-get install -y nginx

如果您想使用 apt-get 安装特定版本的软件包,您只需:

Install Version

sudo apt-get install <package name>=<version>

Nginx

sudo apt-get install nginx=1.5.*

Re (Comment) Option 1: Installing Nginx from its Mainline Repository:

您需要安装密钥以便 Ubuntu 信任来自该存储库的包。

cd /tmp/ && wget http://nginx.org/keys/nginx_signing.key

添加密钥后,运行以下命令在Ubuntu.

上安装Nginx的Mainline存储库或分支
sudo sh -c "echo 'deb http://nginx.org/packages/mainline/ubuntu/ '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/Nginx.list"

sudo apt-get update
sudo apt-get install nginx

Re (Comment) Option 2: Installing Nginx From Its Stable Repository:

sudo sh -c "echo 'deb http://nginx.org/packages/stable/ubuntu/ '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/Nginx.list"
sudo apt-get update
sudo apt-get install nginx

Node:8 使用 debian stretch,所以
1. 在文本编辑器中打开 /etc/apt/sources.list 并在底部添加以下行:

deb http://nginx.org/packages/mainline/debian/ stretch nginx
  1. 导入存储库的包签名密钥并将其添加到 apt:
sudo wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
  1. 安装nginx
sudo apt update
sudo apt install nginx