如何使用 Docker 删除软件包后安装 debian jessie-backports 软件包?

如何使用 Docker 删除软件包后安装 debian jessie-backports 软件包?

问题

我正在尝试使用以下 Dockerfile 在 Ruby on Rails 项目的 docker 存储库中使用 jessie-backports:

FROM ruby:2.4.1
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true

RUN echo 'alias ll="ls --color=auto -l"' >> ~/.bashrc
RUN apt-get remove -y python
RUN apt-get update --fix-missing
RUN apt-get -y upgrade

RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list && apt-get update
RUN apt-get install -y certbot -t jessie-backports

但是,当我尝试构建 docker 映像时。安装过程中出现如下错误:

E: Release file for http://archive.debian.org/debian/dists/jessie-backports/InRelease is expired (invalid since 77d 3h 49min 17s). Updates for this repository will not be applied.

截至3月27日卢卡斯·努斯鲍姆写在这博客文章jessie-updates 和 jessie-backports 将从 Debian 镜像中删除。我提到的博客文章指出我需要做的是替换:

deb http://ftp.debian.org/debian jessie-backports main

使用其他命令:

deb http://archive.debian.org/debian/ jessie-backports main contrib non-free
echo 'Acquire::Check-Valid-Until no;' > /etc/apt/apt.conf.d/99no-check-valid-until

所以我将命令更改如下:

FROM ruby:2.4.1
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true

RUN echo 'alias ll="ls --color=auto -l"' >> ~/.bashrc
RUN apt-get remove -y python
RUN apt-get update --fix-missing
RUN apt-get -y upgrade

RUN echo "deb http://archive.debian.org/debian/ jessie-backports main contrib non-free" > /etc/apt/sources.list
RUN echo 'Acquire::Check-Valid-Until no;' > /etc/apt/apt.conf.d/99no-check-valid-until
RUN apt-get update
RUN apt-get install -y certbot -t jessie-backports

然而同样的问题仍然存在。

我还尝试在任何命令之前移动命令易于像这样的命令:

FROM ruby:2.4.1
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true

RUN echo 'alias ll="ls --color=auto -l"' >> ~/.bashrc

RUN echo "deb http://archive.debian.org/debian/ jessie-backports main contrib non-free" > /etc/apt/sources.list
RUN echo 'Acquire::Check-Valid-Until no;' > /etc/apt/apt.conf.d/99no-check-valid-until
RUN apt-get update

RUN apt-get remove -y python
RUN apt-get update --fix-missing
RUN apt-get -y upgrade
RUN apt-get install -y certbot -t jessie-backports

答案1

为了解决这个问题,我需要提取所有 Debian 主存储库,以便正确安装 certbot。

FROM ruby:2.4.1
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true

RUN echo 'alias ll="ls --color=auto -l"' >> ~/.bashrc

RUN echo "deb http://ftp.debian.org/debian jessie main" > /etc/apt/sources.list
RUN apt-get update

RUN apt-get remove -y python
RUN apt-get update --fix-missing
RUN apt-get -y upgrade

# Let's Encrypt (SSL CERTIFICATES)
RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian/ jessie-backports main" >> /etc/apt/sources.list
RUN echo 'Acquire::Check-Valid-Until no;' >> /etc/apt/apt.conf.d/99no-check-valid-until
RUN apt-get update
RUN apt-get install -y certbot -t jessie-backports

相关内容