Debian

在 debian Bullseye 上安裝特定版本的 NGinx

  • October 21, 2021

我正在使用以下 Dockerfile 建構一個 docker 容器:

FROM debian:bullseye
RUN apt -y update && echo 'deb https://nginx.org/packages/debian/ bullseye nginx' >> /etc/apt/sources.list && echo 'deb-src https://nginx.org/packages/debian/ bullseye nginx' >> /etc/apt/sources.list && apt -y install gnupg2 && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62 && apt -y update && apt -y install nginx nginx-extras luarocks
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
       && ln -sf /dev/stderr /var/log/nginx/error.log
# RUN luarocks install nginx-lua-prometheus
EXPOSE 80

STOPSIGNAL SIGTERM

根據 NGinx 網站上的說明,我將以下兩行添加到etc/apt/sources.list

deb https://nginx.org/packages/debian/ bullseye nginx
deb-src https://nginx.org/packages/debian/ bullseye nginx

並啟動安裝:apt install -y nginx ...

但是,當容器啟動時,版本正在執行:

# nginx -v
nginx version: nginx/1.18.0

似乎 nginx 是從 debian 儲存庫而不是 NGinx 安裝的。

更令人驚訝的是,NGinx 包被標記為可升級:

# apt update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Hit:4 https://nginx.org/packages/debian bullseye InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.

# apt list --upgradable
Listing... Done
nginx/stable 1.20.1-1~bullseye all [upgradable from: 1.18.0-6.1]
N: There is 1 additional version. Please use the '-a' switch to see it

現在,如果我嘗試升級 nginx 包,它會失敗:

# apt upgrade nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libnginx-mod-http-auth-pam : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-cache-purge : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-dav-ext : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-echo : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-fancyindex : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-geoip : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-geoip2 : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-headers-more-filter : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-image-filter : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-lua : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-ndk : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-perl : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-subs-filter : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-uploadprogress : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-upstream-fair : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-http-xslt-filter : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-mail : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-nchan : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-stream : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-stream-geoip : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
libnginx-mod-stream-geoip2 : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
nginx-extras : Depends: nginx-common (= 1.18.0-6.1) but it is not installable
E: Broken packages

我的問題如下:如何直接從 NGinx 儲存庫安裝最新版本(nginx/stable 1.20.1)?

來自man apt

通過在包名稱後面加上等號 (=) 和要選擇的包的版本,可以選擇特定版本的包進行安裝。或者,可以通過在包名稱後加上正斜杠 (/) 和代號(buster、bulseye、sid …)或套件名稱(穩定、測試、不穩定)來選擇特定版本的版本。如果需要滿足請求,這還將從此版本中選擇此版本的版本以獲取此包的依賴項。

軟體包的依賴項也可能存在問題nginx/stable 1.20.1,但是當您嘗試安裝它時會發現。

引用自:https://unix.stackexchange.com/questions/674174