silentArtifact
silentArtifact

Reputation: 41

Docker-compose not reading environment variables (MYSQL_DATABASE_PASSWORD)

I'm attempting to use Portainer's default Wordpress template to build a little wordpress stack, on a Synology NAS. It outright declares MYSQL_DATABASE_PASSWORD, but on run, I get the following:

You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

I've tried the same for FileRun using their default docker-compose.yml file in their documentation, and even that throws the above error.

I've tried exporting any/all of those environment variables, but have found the same issue occurs.

version: '2'

services:
  db:
    image: mariadb:10.1
    environment:
      MYSQL_ROOT_PASSWORD: your_mysql_root_password
      MYSQL_USER: your_filerun_username
      MYSQL_PASSWORD: your_filerun_password
      MYSQL_DATABASE: your_filerun_database
    volumes:
      - /filerun/db:/var/lib/mysql

  web:
    image: afian/filerun
    environment:
      FR_DB_HOST: db
      FR_DB_PORT: 3306
      FR_DB_NAME: your_filerun_database
      FR_DB_USER: your_filerun_username
      FR_DB_PASS: your_filerun_password
      APACHE_RUN_USER: www-data
      APACHE_RUN_USER_ID: 33
      APACHE_RUN_GROUP: www-data
      APACHE_RUN_GROUP_ID: 33
    depends_on:
      - db
    links:
      - db:db
    ports:
      - "80:80"
    volumes:
      - /filerun/html:/var/www/html
      - /filerun/user-files:/user-files

Expected results would be the stack runs, specifically the mariadb container. What actually happens is the container dies, repeatedly, throwing the You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD error.

Upvotes: 4

Views: 5166

Answers (2)

Robert Dundon
Robert Dundon

Reputation: 1168

Came across this question via Google. I was having this issue when seeding a database per this answer.

In the docs that @Siyavash mentions (under "Environment Variables"):

Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.

So the user variables I was using would need be placed in the Dockerfile, and not docker-compose.yml.

Upvotes: 1

Siyavash vaez afshar
Siyavash vaez afshar

Reputation: 1493

As their doc says there is no variable with the name MYSQL_DATABASE_PASSWORD. these are available ones: "Currently, this is only supported for MYSQL_ROOT_PASSWORD, MYSQL_ROOT_HOST, MYSQL_DATABASE, MYSQL_USER, and MYSQL_PASSWORD."

Or maybe I didn't get your issue.

Upvotes: 2

Related Questions