lucahuy
lucahuy

Reputation: 800

apt-get install -y nginx with newer version

In Dockerfile:

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

I think I got a very old version of nginx this way. How can I install a newer version, like 1.15.7? Can I do something like:

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

Upvotes: 1

Views: 3061

Answers (2)

nct
nct

Reputation: 355

Node:8 use debian stretch,so
1. Open /etc/apt/sources.list in a text editor and add the following line to the bottom:

deb http://nginx.org/packages/mainline/debian/ stretch nginx
  1. Import the repository’s package signing key and add it to apt:
sudo wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
  1. Install nginx
sudo apt update
sudo apt install nginx

Upvotes: 2

ABC
ABC

Reputation: 2148

If you want to install a package using apt-get with a specific version, you simply could:

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:

You’ll need to install the key in order for Ubuntu to trust packages from that repository.

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

After adding the key, run the commands below to install Nginx’s Mainline repository or branch on 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

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

Upvotes: 1

Related Questions