We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Docker container crashes if IPv6 is disabled at the system level.
If listen [::] is found somewhere in the configs, but IPv6 is disabled at the host system level and in the docker, then the process crashes, and, accordingly, the docker container also crashes.

This can be manually climbed into each container, corrected, but it is not very convenient.

docker exec mailu_front_1 sed -i '/listen \[/d' /conf/nginx.conf
docker exec mailu_front_1 sed -i '/listen \[/d' /etc/nginx/nginx.conf
docker exec mailu_front_1 sed -i '/listen \[/d' /etc/nginx/http.d/default.conf
docker restart mailu_front_1

docker restart mailu_webdav_1 && docker exec -it mailu_webdav_1 sed -i 's/hosts =.*\[::\].*/hosts = 0.0.0.0:5232/g' /radicale.conf && docker restart mailu_webdav_1


Can you add a container launch option to remove listen [::] from configs?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `core/admin/start.py`
Content:
```
1 #!/usr/bin/env python3
2 
3 import os
4 import logging as log
5 import sys
6 from socrate import system
7 
8 os.system("chown mailu:mailu -R /dkim")
9 os.system("find /data | grep -v /fetchmail | xargs -n1 chown mailu:mailu")
10 system.drop_privs_to('mailu')
11 
12 log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "INFO"))
13 system.set_env(['SECRET'])
14 
15 os.system("flask mailu advertise")
16 os.system("flask db upgrade")
17 
18 account = os.environ.get("INITIAL_ADMIN_ACCOUNT")
19 domain = os.environ.get("INITIAL_ADMIN_DOMAIN")
20 password = os.environ.get("INITIAL_ADMIN_PW")
21 
22 if account is not None and domain is not None and password is not None:
23     mode = os.environ.get("INITIAL_ADMIN_MODE", default="ifmissing")
24     log.info("Creating initial admin account %s@%s with mode %s", account, domain, mode)
25     os.system("flask mailu admin %s %s '%s' --mode %s" % (account, domain, password, mode))
26 
27 def test_DNS():
28     import dns.resolver
29     import dns.exception
30     import dns.flags
31     import dns.rdtypes
32     import dns.rdatatype
33     import dns.rdataclass
34     import time
35     # DNS stub configured to do DNSSEC enabled queries
36     resolver = dns.resolver.Resolver()
37     resolver.use_edns(0, dns.flags.DO, 1232)
38     resolver.flags = dns.flags.AD | dns.flags.RD
39     nameservers = resolver.nameservers
40     for ns in nameservers:
41         resolver.nameservers=[ns]
42         while True:
43             try:
44                 result = resolver.resolve('example.org', dns.rdatatype.A, dns.rdataclass.IN, lifetime=10)
45             except Exception as e:
46                 log.critical("Your DNS resolver at %s is not working (%s). Please see https://mailu.io/master/faq.html#the-admin-container-won-t-start-and-its-log-says-critical-your-dns-resolver-isn-t-doing-dnssec-validation", ns, e)
47             else:
48                 if result.response.flags & dns.flags.AD:
49                     break
50                 log.critical("Your DNS resolver at %s isn't doing DNSSEC validation; Please see https://mailu.io/master/faq.html#the-admin-container-won-t-start-and-its-log-says-critical-your-dns-resolver-isn-t-doing-dnssec-validation.", ns)
51             time.sleep(5)
52 
53 test_DNS()
54 
55 start_command=" ".join([
56     "gunicorn",
57     f"--threads {str(os.cpu_count())}",
58     "-b :80",
59     "--logger-class mailu.Logger",
60     "--worker-tmp-dir /dev/shm",
61     "--access-logfile -" if (log.root.level<=log.INFO) else "",
62     "--error-logfile -",
63     "--preload",
64     "'mailu:create_app()'"])
65 
66 os.system(start_command)
67
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/core/admin/start.py b/core/admin/start.py
--- a/core/admin/start.py
+++ b/core/admin/start.py
@@ -52,15 +52,21 @@
 
 test_DNS()
 
-start_command=" ".join([
-    "gunicorn",
-    f"--threads {str(os.cpu_count())}",
-    "-b :80",
+cmdline = [
+	"gunicorn",
+	"--threads", f"{os.cpu_count()}",
+	# If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4
+	"-b", f"{'[::]' if os.environ.get('SUBNET6') else ''}:80",
     "--logger-class mailu.Logger",
     "--worker-tmp-dir /dev/shm",
-    "--access-logfile -" if (log.root.level<=log.INFO) else "",
-    "--error-logfile -",
-    "--preload",
-    "'mailu:create_app()'"])
+	"--error-logfile", "-",
+	"--preload"
+]
 
-os.system(start_command)
+# logging
+if log.root.level <= log.INFO:
+	cmdline.extend(["--access-logfile", "-"])
+
+cmdline.append("'mailu:create_app()'")
+
+os.system(" ".join(cmdline))

{"golden_diff": "diff --git a/core/admin/start.py b/core/admin/start.py\n--- a/core/admin/start.py\n+++ b/core/admin/start.py\n@@ -52,15 +52,21 @@\n \n test_DNS()\n \n-start_command=\" \".join([\n-    \"gunicorn\",\n-    f\"--threads {str(os.cpu_count())}\",\n-    \"-b :80\",\n+cmdline = [\n+\t\"gunicorn\",\n+\t\"--threads\", f\"{os.cpu_count()}\",\n+\t# If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4\n+\t\"-b\", f\"{'[::]' if os.environ.get('SUBNET6') else ''}:80\",\n     \"--logger-class mailu.Logger\",\n     \"--worker-tmp-dir /dev/shm\",\n-    \"--access-logfile -\" if (log.root.level<=log.INFO) else \"\",\n-    \"--error-logfile -\",\n-    \"--preload\",\n-    \"'mailu:create_app()'\"])\n+\t\"--error-logfile\", \"-\",\n+\t\"--preload\"\n+]\n \n-os.system(start_command)\n+# logging\n+if log.root.level <= log.INFO:\n+\tcmdline.extend([\"--access-logfile\", \"-\"])\n+\n+cmdline.append(\"'mailu:create_app()'\")\n+\n+os.system(\" \".join(cmdline))\n", "issue": "Docker container crashes if IPv6 is disabled at the system level.\nIf listen [::] is found somewhere in the configs, but IPv6 is disabled at the host system level and in the docker, then the process crashes, and, accordingly, the docker container also crashes.\r\n\r\nThis can be manually climbed into each container, corrected, but it is not very convenient.\r\n\r\ndocker exec mailu_front_1 sed -i '/listen \\[/d' /conf/nginx.conf\r\ndocker exec mailu_front_1 sed -i '/listen \\[/d' /etc/nginx/nginx.conf\r\ndocker exec mailu_front_1 sed -i '/listen \\[/d' /etc/nginx/http.d/default.conf\r\ndocker restart mailu_front_1\r\n\r\ndocker restart mailu_webdav_1 && docker exec -it mailu_webdav_1 sed -i 's/hosts =.*\\[::\\].*/hosts = 0.0.0.0:5232/g' /radicale.conf && docker restart mailu_webdav_1\r\n\r\n\r\nCan you add a container launch option to remove listen [::] from configs?\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nimport logging as log\nimport sys\nfrom socrate import system\n\nos.system(\"chown mailu:mailu -R /dkim\")\nos.system(\"find /data | grep -v /fetchmail | xargs -n1 chown mailu:mailu\")\nsystem.drop_privs_to('mailu')\n\nlog.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"INFO\"))\nsystem.set_env(['SECRET'])\n\nos.system(\"flask mailu advertise\")\nos.system(\"flask db upgrade\")\n\naccount = os.environ.get(\"INITIAL_ADMIN_ACCOUNT\")\ndomain = os.environ.get(\"INITIAL_ADMIN_DOMAIN\")\npassword = os.environ.get(\"INITIAL_ADMIN_PW\")\n\nif account is not None and domain is not None and password is not None:\n    mode = os.environ.get(\"INITIAL_ADMIN_MODE\", default=\"ifmissing\")\n    log.info(\"Creating initial admin account %s@%s with mode %s\", account, domain, mode)\n    os.system(\"flask mailu admin %s %s '%s' --mode %s\" % (account, domain, password, mode))\n\ndef test_DNS():\n    import dns.resolver\n    import dns.exception\n    import dns.flags\n    import dns.rdtypes\n    import dns.rdatatype\n    import dns.rdataclass\n    import time\n    # DNS stub configured to do DNSSEC enabled queries\n    resolver = dns.resolver.Resolver()\n    resolver.use_edns(0, dns.flags.DO, 1232)\n    resolver.flags = dns.flags.AD | dns.flags.RD\n    nameservers = resolver.nameservers\n    for ns in nameservers:\n        resolver.nameservers=[ns]\n        while True:\n            try:\n                result = resolver.resolve('example.org', dns.rdatatype.A, dns.rdataclass.IN, lifetime=10)\n            except Exception as e:\n                log.critical(\"Your DNS resolver at %s is not working (%s). Please see https://mailu.io/master/faq.html#the-admin-container-won-t-start-and-its-log-says-critical-your-dns-resolver-isn-t-doing-dnssec-validation\", ns, e)\n            else:\n                if result.response.flags & dns.flags.AD:\n                    break\n                log.critical(\"Your DNS resolver at %s isn't doing DNSSEC validation; Please see https://mailu.io/master/faq.html#the-admin-container-won-t-start-and-its-log-says-critical-your-dns-resolver-isn-t-doing-dnssec-validation.\", ns)\n            time.sleep(5)\n\ntest_DNS()\n\nstart_command=\" \".join([\n    \"gunicorn\",\n    f\"--threads {str(os.cpu_count())}\",\n    \"-b :80\",\n    \"--logger-class mailu.Logger\",\n    \"--worker-tmp-dir /dev/shm\",\n    \"--access-logfile -\" if (log.root.level<=log.INFO) else \"\",\n    \"--error-logfile -\",\n    \"--preload\",\n    \"'mailu:create_app()'\"])\n\nos.system(start_command)\n", "path": "core/admin/start.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nimport logging as log\nimport sys\nfrom socrate import system\n\nos.system(\"chown mailu:mailu -R /dkim\")\nos.system(\"find /data | grep -v /fetchmail | xargs -n1 chown mailu:mailu\")\nsystem.drop_privs_to('mailu')\n\nlog.basicConfig(stream=sys.stderr, level=os.environ.get(\"LOG_LEVEL\", \"INFO\"))\nsystem.set_env(['SECRET'])\n\nos.system(\"flask mailu advertise\")\nos.system(\"flask db upgrade\")\n\naccount = os.environ.get(\"INITIAL_ADMIN_ACCOUNT\")\ndomain = os.environ.get(\"INITIAL_ADMIN_DOMAIN\")\npassword = os.environ.get(\"INITIAL_ADMIN_PW\")\n\nif account is not None and domain is not None and password is not None:\n    mode = os.environ.get(\"INITIAL_ADMIN_MODE\", default=\"ifmissing\")\n    log.info(\"Creating initial admin account %s@%s with mode %s\", account, domain, mode)\n    os.system(\"flask mailu admin %s %s '%s' --mode %s\" % (account, domain, password, mode))\n\ndef test_DNS():\n    import dns.resolver\n    import dns.exception\n    import dns.flags\n    import dns.rdtypes\n    import dns.rdatatype\n    import dns.rdataclass\n    import time\n    # DNS stub configured to do DNSSEC enabled queries\n    resolver = dns.resolver.Resolver()\n    resolver.use_edns(0, dns.flags.DO, 1232)\n    resolver.flags = dns.flags.AD | dns.flags.RD\n    nameservers = resolver.nameservers\n    for ns in nameservers:\n        resolver.nameservers=[ns]\n        while True:\n            try:\n                result = resolver.resolve('example.org', dns.rdatatype.A, dns.rdataclass.IN, lifetime=10)\n            except Exception as e:\n                log.critical(\"Your DNS resolver at %s is not working (%s). Please see https://mailu.io/master/faq.html#the-admin-container-won-t-start-and-its-log-says-critical-your-dns-resolver-isn-t-doing-dnssec-validation\", ns, e)\n            else:\n                if result.response.flags & dns.flags.AD:\n                    break\n                log.critical(\"Your DNS resolver at %s isn't doing DNSSEC validation; Please see https://mailu.io/master/faq.html#the-admin-container-won-t-start-and-its-log-says-critical-your-dns-resolver-isn-t-doing-dnssec-validation.\", ns)\n            time.sleep(5)\n\ntest_DNS()\n\ncmdline = [\n\t\"gunicorn\",\n\t\"--threads\", f\"{os.cpu_count()}\",\n\t# If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4\n\t\"-b\", f\"{'[::]' if os.environ.get('SUBNET6') else ''}:80\",\n    \"--logger-class mailu.Logger\",\n    \"--worker-tmp-dir /dev/shm\",\n\t\"--error-logfile\", \"-\",\n\t\"--preload\"\n]\n\n# logging\nif log.root.level <= log.INFO:\n\tcmdline.extend([\"--access-logfile\", \"-\"])\n\ncmdline.append(\"'mailu:create_app()'\")\n\nos.system(\" \".join(cmdline))\n", "path": "core/admin/start.py"}]}