It is not possible to connect to the database through the container

version: '3'

services:

  db:
    container_name: mariadb
    image: mariadb
    restart: always
    expose:
    - "3306"
    # ports:
    #   - "3308:3306"
    environment:
      MARIADB_ROOT_PASSWORD: root
    networks:
      - network1

  phpmyadmin:
    container_name: phpmyadmin
    image: phpmyadmin
    restart: always
    ports:
      - 9000:80
    environment:
      - PMA_ARBITRARY=1
    networks:
      - network1

  server_1:
    container_name: ${SERVER_1_NAME}
    image: joonk/server-test:latest
    # restart: always
    ports:
      - "${SERVER_1_PORT}:${SERVER_1_PORT}"
    depends_on:
      - db
    environment:
      DB_HOST: db
      DB_PORT: 3306
      DB_NAME: root
      DB_PASSWORD: root
    networks:
      - network1

networks:
  network1:

import express from 'express';
import mariadb from 'mariadb';

const port = process.env.PORT || 4000;
const app = express()

async function asyncFunction() {
    const conn = await mariadb.createConnection({
        host: process.env.DB_HOST ? process.env.DB_HOST : '0.0.0.0',
        user: process.env.DB_USER ? process.env.DB_USER : 'root',
        password: process.env.DB_PASSWORD ? process.env.DB_PASSWORD : 'root',
        port: process.env.DB_PORT ? Number(process.env.DB_PORT) : 3308,
    });

    try {
        const res = await conn.query('select 1', [2]);
        console.log(res); // [{ "1": 1 }] 
        return res;
    } finally {
        conn.end();
    }
}

setTimeout(asyncFunction, 0)

app.listen(port, () => {
    console.log(`Прослушивание порта http://localhost:${port}`)
})