在 debian bullseye 上安装特定版本的 NGinx

在 debian bullseye 上安装特定版本的 NGinx

我正在使用以下 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)?

答案1

man apt

可以通过在程序包名称后面加上等号 (=) 和要选择的程序包版本来选择安装程序包的特定版本。或者,可以通过在软件包名称后面加上正斜杠 (/) 和代号(buster、bullseye、sid ...)或套件名称(稳定、测试、不稳定)来选择特定发行版的版本。如果需要满足请求,这还将从此版本中选择该包的依赖项的版本。

包的依赖项也可能存在问题nginx/stable 1.20.1,但当您尝试安装它时就会发现。

相关内容