summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmail/entrypoint.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/mail/entrypoint.sh b/mail/entrypoint.sh
index 49d8d64..a8b87b4 100755
--- a/mail/entrypoint.sh
+++ b/mail/entrypoint.sh
@@ -15,9 +15,14 @@ if [[ ! -f "$KEY_FILE" ]]; then
fi
# Docker の embedded DNS (127.0.0.11) は MX クエリを解決できないことがあるため
-# 外部 DNS に差し替える(コンテナ内の名前解決は不要なので問題なし)
-sed -i 's/nameserver 127.0.0.11/nameserver 8.8.8.8/' /etc/resolv.conf
-echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
+# 外部 DNS に差し替える(sed -i は bind mount で失敗するため python3 で書き換え)
+python3 - << 'PYEOF'
+path = '/etc/resolv.conf'
+content = open(path).read().replace('nameserver 127.0.0.11', 'nameserver 8.8.8.8')
+if '1.1.1.1' not in content:
+ content += 'nameserver 1.1.1.1\n'
+open(path, 'w').write(content)
+PYEOF
# Start rsyslog for Postfix logging
rsyslogd