apt-get install -y nginx和更高版本

时间:2019-03-22 01:08:27

标签: node.js docker nginx apt-get

在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

2 个答案:

答案 0 :(得分:1)

如果您要使用sudo apt-get install <package name>=<version> 安装特定版本的软件包,只需:

  

安装版本

sudo apt-get install nginx=1.5.*
  

Nginx

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

Re(注释)选项1:从其主线存储库安装Nginx:

您需要安装密钥,以便Ubuntu信任该存储库中的软件包。

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

添加密钥后,运行以下命令以在Ubuntu上安装Nginx的Mainline存储库或分支。

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
  

Re(注释)选项2:从其稳定的存储库安装Nginx:

import turtle
import random

turtle.speed(0)
turtle.hideturtle()
turtle.tracer(0,0)

def draw_line(x,y,angle,length,color,size):
    turtle.up()
    turtle.goto(x,y)
    turtle.seth(angle)
    turtle.color(color)
    turtle.pensize(size)
    turtle.down()
    turtle.forward(length)


def draw_tree(x,y,angle,length,color,size,thiccness,n):
    if n == 0:
       return
    if n <= 3:
       color = 'lime green'
    draw_line(x,y,angle,length,color,size)
    cx = turtle.xcor()
    cy = turtle.ycor()
    draw_tree(cx,cy,angle-thiccness+random.uniform(-8,8),length/(1.3+random.uniform(-.2,.2)),color,size*(0.8+random.uniform(-.1,.1)),thiccness,n-1)
    draw_tree(cx,cy,angle+thiccness+random.uniform(-8,8),length/(1.3+random.uniform(-.2,.2)),color,size*(0.8+random.uniform(-.1,.1)),thiccness,n-1)

draw_tree(0,-350,90,150,'brown',10,30,10)
turtle.update()

答案 1 :(得分:1)

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