docker compose実行時にエラー「ERROR: for postgres Cannot start service postgres11: driver failed programming external connectivity on endpoint postgres」が発生した場合の対処法

docker compose実行時にエラー「ERROR: for postgres  Cannot start service postgres11: driver failed programming external connectivity on endpoint postgres」が発生した場合の対処法

docker composeでpostgres起動時にエラー「ERROR: for postgres Cannot start service postgres11: driver failed programming external connectivity on endpoint postgres」が発生した場合の対処法を記述してます。

環境

  • OS Rocky Linux release 8.4 (Green Obsidian)
  • docker 20.10.8
  • docker-compose 1.29.2

エラー内容

「docker-compose up -d」実行時に発生。

エラー全文は以下となります。

Starting postgres ... 
Starting postgres ... error

ERROR: for postgres  Cannot start service postgres11: driver failed programming external connectivity on endpoint postgres (f4ec0b740f2c50bc802cd0f5baf9bdd7eebecef58d223c066bbfd526dd5e5d82):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 5432 -j DNAT --to-destination 172.18.0.2:5432 ! -i br-xxxxxx: iptables: No chain/target/match by that name.
 (exit status 1))

ERROR: for postgres11  Cannot start service postgres11: driver failed programming external connectivity on endpoint postgres (f4ec0b740f2c50bc802cd0f5baf9bdd7eebecef58d223c066bbfd526dd5e5d82):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 5432 -j DNAT --to-destination 172.18.0.2:5432 ! -i br-xxxxxx: iptables: No chain/target/match by that name.
 (exit status 1))
ERROR: Encountered errors while bringing up the project.

対処法

firewallを止めていたことが原因。fiwallを起動すれば自分の場合は、解決しました。

sudo systemctl start firewalld