ホストを解決できませんでした: github.com

こんにちは。

./launcher rebuild app

fatal: ‘GitHub - discourse/discourse: A platform for community discussion. Free, open, simple.’ にアクセスできません: github.com を解決できません

しかし

root@discourse:/var/discourse# host github.com
github.com has address 140.82.121.3
github.com mail is handled by 1 aspmx.l.google.com.
github.com mail is handled by 10 alt4.aspmx.l.google.com.
github.com mail is handled by 10 alt3.aspmx.l.google.com.
github.com mail is handled by 5 alt1.aspmx.l.google.com.
github.com mail is handled by 5 alt2.aspmx.l.google.com.

何か考えはありますか?

よろしくお願いします。


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && sudo -H -E -u discourse bash -c '
  set -o errexit
  if [ $(git rev-parse --is-shallow-repository) == "true" ]; then
      git remote set-branches --add origin main
      git remote set-branches origin tests-passed
      git fetch --depth 1 origin tests-passed
  else
      git fetch --tags --prune-tags --prune --force origin
  fi
' failed with return #<Process::Status: pid 144 exit 128>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"code", "cmd"=>["sudo -H -E -u discourse git clean -f", "sudo -H -E -u discourse bash -c '\n  set -o errexit\n  if [ $(git rev-parse --is-shallow-repository) == \"true\" ]; then\n      git remote set-branches --add origin main\n      git remote set-branches origin $version\n      git fetch --depth 1 origin $version\n  else\n      git fetch --tags --prune-tags --prune --force origin\n  fi\n'", "sudo -H -E -u discourse bash -c '\n  set -o errexit\n  if [[ $(git symbolic-ref --short HEAD) == $version ]] ; then\n      git pull\n  else\n      git -c advice.detachedHead=false checkout $version\n  fi\n'", "sudo -H -E -u discourse git config user.discourse-version $version", "mkdir -p tmp", "chown discourse:www-data tmp", "mkdir -p tmp/pids", "mkdir -p tmp/sockets", "touch tmp/.gitkeep", "mkdir -p                    /shared/log/rails", "bash -c \"touch -a           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log\"", "bash -c \"ln    -s           /shared/log/rails/{production,production_errors,unicorn.stdout,unicorn.stderr,sidekiq}.log $home/log\"", "bash -c \"mkdir -p           /shared/{uploads,backups}\"", "bash -c \"ln    -s           /shared/{uploads,backups} $home/public\"", "bash -c \"mkdir -p           /shared/tmp/{backups,restores}\"", "bash -c \"ln    -s           /shared/tmp/{backups,restores} $home/tmp\"", "chown -R discourse:www-data /shared/log/rails /shared/uploads /shared/backups /shared/tmp\"", "[ ! -d public/plugins ] || find public/plugins/ -maxdepth 1 -xtype l -delete"]}
bootstrap failed with exit code 128

それはコンテナ内にあるので、Dockerのネットワーク問題か、一時的な問題だった可能性があります。

コンテナはデフォルトでホストの /etc/resolv.conf を使用していますか? nameserver 127.0.0.1 のようなローカルリゾルバがある場合、コンテナ内からは利用できないと思います。Unbound は Docker コンテナが使用する 172.16.0.0/12 を含むすべての予約済み IP アドレス範囲からのクエリを許可するように設定されているため、これは問題ではありません。

しかし、再構築時に同じ問題が発生し、その間に独自の Unbound を設定し、/etc/resolv.conf から以前のように nameserver 1.1.1.1 のみの行を削除した後でも、再構築は同じ箇所で失敗します。キャッシュされている可能性はありますか? :thinking:

ホストからは、github.com は問題なく解決できます。

編集:いいえ、/etc/resolv.conf はもう問題ではありません。デバッグ出力を追加しました。

I, [2025-09-25T17:32:38.092043 #1]  INFO -- : cd /var/www/discourse && cat /etc/resolv.conf
I, [2025-09-25T17:32:38.093195 #1]  INFO -- : # Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 1.1.1.1

# Based on host file: '/etc/resolv.conf' (legacy)
# Overrides: []

I, [2025-09-25T17:32:38.093221 #1]  INFO -- : cd /var/www/discourse && getent hosts github.com
I, [2025-09-25T17:32:58.111177 #1]  INFO -- :
I, [2025-09-25T17:32:58.111456 #1]  INFO -- : Terminating async processes

編集:apt update も永遠にハングし、テスト用の curl も失敗します。どちらもネットワークがオンラインかどうかを確認するために Discourse テンプレートに追加したテストです。nameserver 9.9.9.9 も機能しないため、コンテナにはネットワークアクセスがないようですが、理由は不明です。

… 編集2:私たちの場合は、Fail2Ban が無効なユーザーアカウントのメールアドレスにメールを送信しようとしたためにコンテナ IP を禁止し、Fail2Ban Postfix フィルターをトリガーしました :smile:

したがって、コンテナにネットワークがない場合は、Fail2Ban を確認することがデバッグステップの 1 つになります。

編集3:Fail2Ban の jail 設定で:

ignoreip = 127.0.0.1/8 172.16.0.0/12

ループバックおよび Docker IP が禁止されるのを回避するため。