AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1052329
Accepted
Simon
Simon
Asked: 2021-02-04 15:52:09 +0800 CST2021-02-04 15:52:09 +0800 CST 2021-02-04 15:52:09 +0800 CST

“致命:未知服务:smtp/tcp”来自使用`start-fg`的docker中的后缀

  • 772

我试图让后缀在树莓派上的 docker 容器中工作。以下作品

ENTRYPOINT service rsyslog restart && service postfix restart && sleep 2s && tail /var/log/syslog -f

但是,如果我改为使用以下内容,这意味着在前台运行 postfix(根据文档,并从serverfault链接)

ENTRYPOINT postfix start-fg

然后它会启动,但是任何发送邮件的尝试都会导致fatal: unknown service: smtp/tcp


我的master.cf包含

# service type  private unpriv  chroot  wakeup  maxproc command + args
smtp       inet  n       -       y       -       -       smtpd

但是在阅读了有关 chroot 的许多其他问题后,我尝试将其关闭,但没有成功。

我还检查了两者中都存在 smtp/etc/services并且/var/spool/postfix/etc/services权限是开放的以供阅读。我确保这一点

RUN ln -snf /etc/services /var/spool/postfix/etc/services
-rw-r--r-- 1 root root 18774 Feb  3 23:28 /var/spool/postfix/etc/services
-rw-r--r-- 1 root root 18774 Feb 10  2019 /etc/services
#grep smtp /var/spool/postfix/etc/services
smtp        25/tcp      mail
submissions 465/tcp     ssmtp smtps urd # Submission over TLS [RFC8314]
#grep smtp /etc/services
smtp        25/tcp      mail
submissions 465/tcp     ssmtp smtps urd # Submission over TLS [RFC8314]


我完整的 dockerfile

FROM --platform=linux/arm/v7 debian:stable-slim
RUN apt-get update
RUN apt-get install postfix rsyslog -y
COPY etc /etc # I have main.cf, mcaster.cf, virtual, and mailname copying in
# Build the virtual.db database file
RUN postmap /etc/postfix/virtual
# This gets smtp working https://serverfault.com/questions/655116/postfix-fails-to-send-mail-with-fatal-unknown-service-smtp-tcp
RUN ln -snf /etc/services /var/spool/postfix/etc/services
EXPOSE 25
ENTRYPOINT service rsyslog restart && service postfix restart && sleep 2s && tail /var/log/syslog -f
#ENTRYPOINT postfix start-fg

我真的更喜欢将start-fg两者用于在容器中拥有单个进程的最佳实践,并且它将使 syslog 日志管理更清晰。


如果我没有包含重要的内容或者我可以获取有用的日志,请发表评论。我在 linux 上处于中级水平,所以我会尽力获取日志和跟踪信息,但可能需要一些指导。

postfix docker raspbian
  • 1 1 个回答
  • 307 Views

1 个回答

  • Voted
  1. Best Answer
    bmccormick
    2021-02-25T18:57:27+08:002021-02-25T18:57:27+08:00

    抱歉,我对此很陌生,但我会试一试:当你使用它时postfix start-fg,它将在 chroot 环境中启动后缀进程。Postfix 需要访问其中的一些文件/etc(就像你提到的那样/etc/services)。基于后缀文档:

    请注意,chrooted 守护进程解析所有与 Postfix 队列目录(/var/spool/postfix)相关的文件名。为了成功使用 chroot jail,大多数 UNIX 系统要求您引入一些文件或设备节点。源代码分发中的examples/chroot-setup 目录包含一组脚本,可帮助您在不同的操作系统上设置Postfix chroot 环境。

    因此,用户有责任确保填充 chroot jail(获取所有文件和库)以使 postfix 按预期工作。这是 postfix 提供的用于设置 chroot 环境的脚本。您可以看到它从 /etc 以及一些库复制文件。

    #! /bin/sh
    
    # LINUX2 - shell script to set up a Postfix chroot jail for Linux
    # Tested on SuSE Linux 5.3 (libc5) and 7.0 (glibc2.1)
    
    # Other testers reported as working:
    #
    # 2001-01-15 Debian sid (unstable)
    #            Christian Kurz <[email protected]>
    
    # Copyright (c) 2000 - 2001 by Matthias Andree
    # Redistributable unter the MIT-style license that follows:
    # Abstract: "do whatever you want except hold somebody liable or change
    # the copyright information".
    
    # Permission is hereby granted, free of charge, to any person obtaining a copy
    # of this software and associated documentation files (the "Software"), to
    # deal in the Software without restriction, including without limitation the
    # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    # sell copies of the Software, and to permit persons to whom the Software is
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in
    # all copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    # IN THE SOFTWARE.
    
    # 2000-09-29
    # v0.1: initial release
    
    # 2000-12-05
    # v0.2: copy libdb.* for libnss_db.so
    #       remove /etc/localtime in case it's a broken symlink
    #       restrict find to maxdepth 1 (faster)
    
    # Revision 1.4  2001/01/15 09:36:35  emma
    # add note it was successfully tested on Debian sid
    #
    # 20060101 /lib64 support by Keith Owens.
    #
    
    CP="cp -p"
    
    cond_copy() {
      # find files as per pattern in $1
      # if any, copy to directory $2
      dir=`dirname "$1"`
      pat=`basename "$1"`
      lr=`find "$dir" -maxdepth 1 -name "$pat"`
      if test ! -d "$2" ; then exit 1 ; fi
      if test "x$lr" != "x" ; then $CP $1 "$2" ; fi
    } 
    
    set -e
    umask 022
    
    POSTFIX_DIR=${POSTFIX_DIR-/var/spool/postfix}
    cd ${POSTFIX_DIR}
    
    mkdir -p etc lib usr/lib/zoneinfo
    test -d /lib64 && mkdir -p lib64
    
    # find localtime (SuSE 5.3 does not have /etc/localtime)
    lt=/etc/localtime
    if test ! -f $lt ; then lt=/usr/lib/zoneinfo/localtime ; fi
    if test ! -f $lt ; then lt=/usr/share/zoneinfo/localtime ; fi
    if test ! -f $lt ; then echo "cannot find localtime" ; exit 1 ; fi
    rm -f etc/localtime
    
    # copy localtime and some other system files into the chroot's etc
    $CP -f $lt /etc/services /etc/resolv.conf /etc/nsswitch.conf etc
    $CP -f /etc/host.conf /etc/hosts /etc/passwd etc
    ln -s -f /etc/localtime usr/lib/zoneinfo
    
    # copy required libraries into the chroot
    cond_copy '/lib/libnss_*.so*' lib
    cond_copy '/lib/libresolv.so*' lib
    cond_copy '/lib/libdb.so*' lib
    if test -d /lib64; then
      cond_copy '/lib64/libnss_*.so*' lib64
      cond_copy '/lib64/libresolv.so*' lib64
      cond_copy '/lib64/libdb.so*' lib64
    fi
    
    postfix reload
    
    • 1

相关问题

  • Postfix 在特定端口上接受邮件

  • 让 Postfix 以两种方式处理垃圾邮件

  • Postfix 或 exim:自动/程序化和转发电子邮件设置

  • 后缀电子邮件地址

  • 什么是最好的开源电子邮件解决方案包

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve