title: MYSQL_ROOT_PASSWORD environment variable is not set for mariadb container if I using .env file in swarm
body: <p>When I try to set up a cluster with docker swarm I receive this error:</p>
  <pre><code>$ docker logs 6ea0f7290cb0  
  2020-11-30 10:46:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
  2020-11-30 10:46:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
  2020-11-30 10:46:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
  2020-11-30 10:46:08+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
          You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
  </code></pre>
  <p>What is weird because if I use the docker-compose tool, everything works well.</p>
  <p>To replicate this problem follow the steps below.</p>
  <p>Create a <code>.env</code> file:</p>
  <pre><code>DB_NAME=nest
  DB_USERNAME=nest
  DB_PASSWORD=nest
  DB_ROOT_PASSWORD=nest
  </code></pre>
  <p>Create a <code>docker-compose.yml</code> file:</p>
  <pre><code>version: '3.8'
  
  services:
  
    db:
      image: mariadb
      environment:
        MYSQL_ROOT_PASSWORD: &quot;${DB_ROOT_PASSWORD}&quot;
  
  </code></pre>
  <p>If I use the command <code>docker-compose up -d</code>, I can check that everything works well with the <code>docker-compose ps</code> command:</p>
  <pre><code>$ docker-compose ps
      Name                  Command             State    Ports  
  --------------------------------------------------------------
  db-debug_db_1   docker-entrypoint.sh mysqld   Up      3306/tcp
  </code></pre>
  <p>If I use the command <code>docker stack deploy -c docker-compose.yml db</code>, I can check that the database is not started with the command <code>docker service ls</code>:</p>
  <pre><code>$ docker service ls
  ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
  ux1p4k6vwiyh        db_db               replicated          0/1                 mariadb:latest
  </code></pre>