首页 > 解决方案 > apt-get install -y nginx 更新版本

问题描述

在 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

标签: node.jsdockernginxapt-get

解决方案


Node:8 使用 debian 拉伸,所以
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

推荐阅读