Configure Metabase connection at Docker Level

Is there a way to configure a DB connection in a docker-compose.yaml file?

I would ideally like to be able to configure the connection details (host, username, password, etc.) in the YAML file if possible.

services:
  metabase:
    container_name: metabase-server
    image: metabase/metabase:latest
    hostname: metabase
    volumes:
      - /dev/urandom:/dev/random:ro
    ports:
      - 3001:3000
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabaseappdb
      MB_DB_PORT: 5432
      MB_DB_USER: metabase
      MB_DB_PASS: mysecretpassword
      MB_DB_HOST: postgres
    networks:
      - metabase-network
    healthcheck:
      test: curl --fail -I http://localhost:3001/api/health || exit 1
      interval: 15s
      timeout: 5s
      retries: 5

  postgres:
    image: postgres:latest
    container_name: postgres
    hostname: postgres
    environment:
      POSTGRES_USER: metabase
      POSTGRES_DB: metabaseappdb
      POSTGRES_PASSWORD: mysecretpassword
    networks:
      - metabase-network
    volumes:
      - postgres-data:/var/lib/postgresql/data

networks:
  metabase-network:
    driver: bridge

volumes:
  postgres-data: