I have a problem with docker-compose and mysql:
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/   An error occurred when I compose this container:
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   But the database don't have a password. How can I solve it?
MYSQL_RANDOM_ROOT_PASSWORD. This is an optional variable. Set to a non-empty value, like yes , to generate a random initial password for the root user (using pwgen ). The generated root password will be printed to stdout ( GENERATED ROOT PASSWORD: ..... ).
The docker compose up command aggregates the output of each container (like docker compose logs --follow does). When the command exits, all containers are stopped. Running docker compose up --detach starts the containers in the background and leaves them running.
According the documentation, instead of MYSQL_ROOT_PASSWORD: you have to use - and = and also you should use a 'password' The result it will be:
- MYSQL_ROOT_PASSWORD=some_password
In your example:
version: '2'    services:    db:     image: mysql     volumes:       - "./sito/db/:/var/lib/mysql"     ports:       - "3306:3306"     restart: always     environment:       - MYSQL_ROOT_PASSWORD=some_password 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With