“致命:未知服務:smtp/tcp”來自使用start-fg
的docker中的後綴
我試圖讓後綴在樹莓派上的 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 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 <shorty@getuid.de> # 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