2016-09-24 3 views
3

Ich habe ein Problem mit Docker-compose und mysql:Docker-compose: Datenbank ist nicht initialisierten

Docker-compose.yml

version: '2' 
    services: 
    db: 
    image: mysql 
    volumes: 
     - "./sito/db/:/var/lib/mysql" 
    ports: 
     - "3306:3306" 
    restart: always 
    environment: 
     MYSQL_ROOT_PASSWORD: 

    app: 
    depends_on: 
     - db 
    image: eboraas/apache-php 
    links: 
     - db 
    ports: 
     - "80:80" 
    volumes: 
     - ./sito/:/var/www/html/ 

ist ein Fehler aufgetreten, als ich diesen Behälter zusammensetzen:

Recreating phpapp_phpapache_1 
Attaching to phpapp_db_1, phpapp_phpapache_1 
db_1 | error: database is uninitialized and password option is not specified 
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD 
phpapache_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.30.0.3. Set the 'ServerName' directive globally to suppress this message 
phpapp_db_1 exited with code 1 
db_1 | error: database is uninitialized and password option is not specified 
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD 
db_1 | error: database is uninitialized and password option is not specified 
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD 
db_1 | error: database is uninitialized and password option is not specified 
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD 
db_1 | error: database is uninitialized and password option is not specified 

Aber die Datenbank hat kein Passwort. Wie kann ich es lösen?

+0

Mögliche duplicat e von [docker, MYSQL \ _ROOT \ _PASSWORD funktionieren nicht] (http://stackoverflow.com/questions/40149880/docker-mysql-root-password-do-not-work) – mayo

Antwort

3

Es sieht so aus, als würden Sie die auf Null setzen. Laut Dokumentation ist es erforderlich.

https://hub.docker.com/_/mysql/

MYSQL_ROOT_PASSWORD

Diese Variable ist obligatorisch und gibt das Kennwort, die für die MySQL-root-Superuser-Account festgelegt wird.

3

der documentation Nach statt MYSQL_ROOT_PASSWORD: Sie haben verwenden - und = und auch Sie sollten ein 'Passwort' verwenden Das Ergebnis wird es sein:

- MYSQL_ROOT_PASSWORD=some_password

In Ihr Beispiel:

version: '2' 
    services: 
    db: 
    image: mysql 
    volumes: 
     - "./sito/db/:/var/lib/mysql" 
    ports: 
     - "3306:3306" 
    restart: always 
    environment: 
     - MYSQL_ROOT_PASSWORD=some_password 
Verwandte Themen