Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

525
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda