Back

[SOLVED] With my firewall running, several of my containers keep restarting

  • 0
  • Self Hosted
mauricev
12 Jun, 2023, 20:51

Here is my firewall configuration: table ip filter { set blacklist { type ipv4_addr flags interval elements = { 46.229.168.0/24 } }

TypeScript
chain input {
    type filter hook input priority filter; policy drop;
    ip saddr @blacklist drop
    ct state invalid drop
    iif "lo" accept
    icmp type echo-request limit rate over 10/second burst 4 packets drop
    ct state established,related accept
    icmp type { destination-unreachable, echo-request, router-advertisement, router-solicitation, time-exceeded, parameter-problem } accept
    ip protocol igmp accept
    ip saddr { 8.8.8.0/24, 47.19.177.245-47.19.177.246 } tcp dport 22 ct state new accept
    ip saddr { 47.19.177.245, 47.19.177.246 } tcp dport 497 ct state new accept
    tcp dport 443 accept
}

chain FORWARD {
    type filter hook forward priority filter; policy drop;
}

chain OUTPUT {
    type filter hook output priority filter; policy accept;
}

}

TL;DR
The user was experiencing an issue with their firewall causing several of their Docker containers to keep restarting. They discovered that Docker sets up its own rules using IPtables, which don't mix well with nftables. They converted their rules to iptables, which resolved the problem. There is no further solution or troubleshooting mentioned in the thread.
Drake
12 Jun, 2023, 20:59

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

Drake
12 Jun, 2023, 21:00

some questions:

  1. how did you install Appwrite?
  2. what's the output of docker ps -a show?
  3. what do the logs in the appwrite container show?
mauricev
12 Jun, 2023, 21:09

I installed it with an .env file with everything prepared.

mauricev
12 Jun, 2023, 21:12
mauricev
12 Jun, 2023, 21:14
TypeScript
Database not ready. Retrying connection (2)...
Database not ready. Retrying connection (3)...
Database not ready. Retrying connection (4)...
Database not ready. Retrying connection (5)...
Database not ready. Retrying connection (6)...
Database not ready. Retrying connection (7)...
Database not ready. Retrying connection (8)...
Database not ready. Retrying connection (9)...
Database not ready. Retrying connection (10)...

Fatal error: Uncaught Exception: Failed to connect to database: SQLSTATE[HY000] [2002] Operation timed out in /usr/src/code/app/http.php:77
Stack trace:
#0 {main}
  thrown in /usr/src/code/app/http.php on line 77
[2023-06-12 21:13:42 #1.1]    ERROR    php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Uncaught Exception: Failed to connect to database: SQLSTATE[HY000] [2002] Operation timed out in /usr/src/code/app/http.php:77
Stack trace:
#0 {main}
  thrown in /usr/src/code/app/http.php on line 77
Drake
12 Jun, 2023, 21:27

Can you explain with some more detail?

mauricev
12 Jun, 2023, 21:29

I setup a number of variables in .env like the password, email address, etc.

mauricev
12 Jun, 2023, 21:30

I'm not sure how the firewall can block access to the database. It's configured to allow connections on localhost

Drake
12 Jun, 2023, 21:36

How did you get the compose file? What did you run to start Appwrite?

mauricev
12 Jun, 2023, 21:37

I just downloaded the current compose file for 1.3.7. what I had was for 1.3.4. I just launch docker and it automatically runs appwrite.

mauricev
12 Jun, 2023, 21:37

If I turn off the firewall and run docker, appwrite runs OK.

Drake
12 Jun, 2023, 21:41

What did you set the DB host env var to?

Did you change the password after mariadb had already started?

Drake
12 Jun, 2023, 21:41

And you're running Appwrite by running docker compose up -d?

Drake
12 Jun, 2023, 21:41

Where did you get the compose file from?

mauricev
12 Jun, 2023, 21:42

_APP_DB_HOST=mariadb; /usr/bin/docker compose up -d --remove-orphans and https://appwrite.io/install/compose

Drake
12 Jun, 2023, 23:08

ya that's all good and that is odd the firewall blocks the traffic. would you please share the output of docker inspect network appwrite_appwrite (assuming your docker compose file is in a folder named appwrite)?

mauricev
13 Jun, 2023, 00:47

attached

Drake
13 Jun, 2023, 01:14

im really bad at firewall stuff but maybe your firewall configuration is missing the docker related rules? https://docs.docker.com/network/packet-filtering-firewalls/

I was also trying to see if there was anything related to 172.20.0.X but i can't tell

mauricev
14 Jun, 2023, 04:53

As that link mentions, docker sets up its own rules using IPtables. I am using nftables and apparently they still don't mix well. I converted my rules to iptables and that resolved the problem. Thanks for your help.

Drake
14 Jun, 2023, 04:55

[SOLVED] With my firewall running, several of my containers keep restarting

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more