I have a docker-compose file with a database service that gets an environment file for users and passwords (I removed the env variable for the password as the problem is the same for both user and password): 

```
db:
    restart: always
    container_name: db
    image: mariadb:10.3.9
    env_file:
      - my_env_file.env
    volumes:
      - /opt/dbdata:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysql", "-u", "${DB_USER}", "-e", "\"SHOW DATABASES;\""]
      interval: 1m
      timeout: 10s
      retries: 10

```

The environment file has a DB\_USER entry:

`DB_USER=TEST`

When building and starting the container with docker-compose, the environment variable cannot be resolved by Docker since the variable only exists in the `db` container, and I'm getting the following warning:

`WARNING: The DB_USER variable is not set. Defaulting to a blank string.`

Is there a way to tell Docker to avoid resolving the value of this env variable on the host, but instead resolve it from my container?

I **do not want** to provide the env variable on the host for security reasons.

I also **do not want** to use `mysqladmin` as it can result in false positives (e.g., healthcheck may fail because database is not yet accepting connections).