Frappe Docker Resolving mariadb service to wrong Ip Address

I had successfully setup docker as development environment for erpnext/frappe on my Digital Ocean server. The whole setup was working fine. But when I restart the server, docker start to resolve maridb on wrong ip address. Here is the my docker inspect.

[
    {
        "Name": "frappe_docker_devcontainer_default",
        "Id": "51debc49dee8e61928a42ef5583dfb32de884a8ad1451961013e392ef76d0dc4",
        "Created": "2022-09-20T08:19:08.151461286Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "045b1aa29bc3124e6ad792241547f7a646c60f39a868e46ea798b500994181d3": {
                "Name": "frappe_docker_devcontainer-redis-socketio-1",
                "EndpointID": "caa2cc8da1bfbbeefeb54ab8cd4f9add3baaad6107e689ee869f3cf029337a97",
                "MacAddress": "02:42:ac:12:00:06",
                "IPv4Address": "172.18.0.6/16",
                "IPv6Address": ""
            },
            "0db2824aebcea9507eb43db0c93a3a598613938a4c02b054bac897dbdf4b089a": {
                "Name": "frappe_docker_devcontainer-redis-cache-1",
                "EndpointID": "89ecd8e23c9c657730fb7502cc114193505dffd30209de0444657a86237411ef",
                "MacAddress": "02:42:ac:12:00:04",
                "IPv4Address": "172.18.0.4/16",
                "IPv6Address": ""
            },
            "3ffc5d97a7f775735736b8ff5d3af5065ca9eb22d8a25c4fed507456da05f173": {
                "Name": "frappe_docker_devcontainer-mariadb-1",
                "EndpointID": "9b3ac1caf0c1bb7e8edc30b32700cc222ddd10c3baa90c480e4781c8b2ffab21",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            },
            "5ec38876e8ebd366a33210ba722422505af6a337a7e9e7a787293239d9caa2e0": {
                "Name": "frappe_docker_devcontainer-redis-queue-1",
                "EndpointID": "051a5dbe9c5f0329984892cd211ffec88949b67b94f2514452ead0c52829cf18",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            },
            "bc9d6c05ce6e36f5829dab62d5d6ffd4155bcbd4faa7064a13fc7de1e082fb85": {
                "Name": "frappe_docker_devcontainer-frappe-1",
                "EndpointID": "054ff4ce7cd56bd41ca76158c854113e52f8c74ca8cac321c715a9404e51e869",
                "MacAddress": "02:42:ac:12:00:05",
                "IPv4Address": "172.18.0.5/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "frappe_docker_devcontainer",
            "com.docker.compose.version": "2.10.2"
        }
    }
]

When I try to open erpnext in my browser. I get error

"Access denied for user '_9bf3e1b642e1907a'@'172.18.0.5

Clearly frappe can’t access Database. The correct ip address for mariadb is 172.18.0.2. Did anyone face similar issue.

My common_site_config looks like this

{
 "db_host":"mariadb",
 "background_workers": 1,
 "file_watcher_port": 6787,
 "frappe_user": "frappe",
 "gunicorn_workers": 5,
 "live_reload": true,
 "rebase_on_pull": false,
 "redis_cache": "redis://redis-cache:6379",
 "redis_queue": "redis://redis-queue:6379",
 "redis_socketio": "redis://redis-socketio:6379",
 "restart_supervisor_on_update": false,
 "restart_systemd_on_update": false,
 "serve_default_site": true,
 "shallow_clone": true,
 "socketio_port": 9000,
 "use_redis_auth": false,
 "webserver_port": 8000
}

Check this frappe_docker/troubleshoot.md at main · frappe/frappe_docker · GitHub

There is a section under troubleshoot for mariadb.