Docker: 无法修正问题,您持有破包

Docker: Unable to correct problems, you have held broken packages

我有一个 Dockerfile,我使用了很多次都没有问题。现在我需要向它添加一些包(ssmtp 和 sendmail),当我添加它们时构建失败:

Sending build context to Docker daemon 645.3 MB
Sending build context to Docker daemon 
Step 0 : FROM debian:jessie
 ---> 736e5442e772
Step 1 : MAINTAINER Larry Martell <larry.martell@foo.com>
 ---> Using cache
 ---> bd272aa26940
Step 2 : ENV HOME /opt/django/CAPgraph/
 ---> Using cache
 ---> 1c540ed91808
Step 3 : RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
 ---> Using cache
 ---> 8788d48e625d
Step 4 : RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf ssmtp sendmail)
 ---> Running in 8986bca93fdb
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://security.debian.org jessie/updates/main amd64 Packages [436 kB]
Get:3 http://http.debian.net jessie-backports InRelease [166 kB]
Get:4 http://httpredir.debian.org jessie-updates InRelease [145 kB]
Get:5 http://http.debian.net jessie-backports/main amd64 Packages [1031 kB]
Get:6 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Ign http://httpredir.debian.org jessie InRelease
Get:7 http://httpredir.debian.org jessie Release.gpg [2373 B]
Get:8 http://httpredir.debian.org jessie Release [148 kB]
Get:9 http://httpredir.debian.org jessie/main amd64 Packages [9049 kB]
Fetched 11.1 MB in 9s (1211 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
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:
 sendmail : Depends: sendmail-bin but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf ssmtp sendmail)' returned a non-zero code: 100

如果我将这些包添加到列表中,我就会抱怨其他包。 'held broken packages' 消息是什么意思,我该如何解决?

这是我的 Dockerfile 的第一部分:

FROM debian:jessie ENV HOME /opt/django/CAPgraph/ 
RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list 
RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf sendmail ssmtp)

我尝试添加 sendmail-bin 但失败了:

The following packages have unmet dependencies:
 sendmail-bin : Conflicts: mail-transport-agent
 ssmtp : Conflicts: mail-transport-agent
E: Unable to correct problems, you have held broken packages.

然后我添加了邮件传输代理,但失败了:

Package mail-transport-agent is a virtual package provided by:
  opensmtpd 5.7.3p2-1~bpo8+1
  ssmtp 2.64-8
  sendmail-bin 8.14.4-8+deb8u1
  qmail-run 2.0.2+nmu1
  postfix 2.11.3-1
  nullmailer 1:1.13-1+deb8u1
  msmtp-mta 1.4.32-2
  masqmail 0.2.30-1
  lsb-invalid-mta 4.1+Debian13+nmu1
  exim4-daemon-light 4.84.2-2+deb8u3
  exim4-daemon-heavy 4.84.2-2+deb8u3
  esmtp-run 1.2-12
  dma 0.9-1
  courier-mta 0.73.1-1.6
  citadel-mta 8.24-1+b3

E: Package 'mail-transport-agent' has no installation candidate

Debian 设置为只允许一个邮件传输代理,而您的安装命令试图包括两个,ssmtp 和 sendmail/sendmail-bin。由于它们相互冲突,您需要从安装命令中删除其中之一。

如果 sendmail 依赖项使您的 Python 应用程序可以通过 sendmail 二进制文件发送电子邮件,只需安装 ssmtp 并将其配置为使用外部 MTA。

不建议尝试 运行 在 Docker 容器中发送邮件