Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

523
Views
Why does MySQL Docker container complain that MYSQL_ROOT_PASSWORD env must be defined when using Docker 17.03 secrets?

I'm trying to adapt Docker's Wordpress secret example (link below) to work in my Docker Compose setup (for Drupal).

https://docs.docker.com/engine/swarm/secrets/#/advanced-example-use-secrets-with-a-wordpress-service

However, when the 'mysql' container is spun up, the following error is output:

"error: 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"

I created the secrets using the 'docker secret create' command:

docker secret create mysql_root_pw tmp-file-holding-root-pw.txt
docker secret create mysql_pw tmp-file-holding-pw.txt

After running the above, the secrets 'mysql_root_pw' and 'mysql_pw' now exist in the swarm environment. Verified by doing:

docker secret ls

Here are the relevant parts from my docker-compose.yml file:

version: '3.1'
services:
  mysql:
    image: mysql/mysql-server:5.7.17 
   environment:
      - MYSQL_ROOT_PASSWORD_FILE="/run/secrets/mysql_root_pw"
      - MYSQL_PASSWORD_FILE="/run/secrets/mysql_pw"
    secrets:
      - mysql_pw
      - mysql_root_pw

secrets:
  mysql_pw:
    external: true
  mysql_root_pw:
    external: true

When I do "docker stack deploy MYSTACK", I get the error mentioned above when the 'mysql' container attempts to start.

It seems like "MYSQL_PASSWORD_FILE" and "MYSQL_ROOT_PASSWORD_FILE" are not standard environment variables recognized by MySQL, and it's still expecting "MYSQL_ROOT_PASSWORD" environment variable.

I'm using Docker 17.03.

Any suggestions?

Thanks.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You get this error if your secret is a empty string as well. That is what happened to me, secret is mounted and service properly configured, but still fails because there is not password.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!