Docker Community Forums

Share and learn in the Docker community.

Docker wordpress mysql connect issue

I am absolutely new to Docker and trying to create a wordpress mysql container in Docker Desktop for Windows 2.1.5 using a docker-compose file. Wordpess is unable to connect to mysql
Access denied for user ‘root’@‘172.17.0.3’ (using password: YES). When I use the following Docker run commands to start the containers, it works:
docker run --name mysql -e MYSQL_ROOT_PASSWORD=mysqlron -d mysql:5.7
docker run --name wordpress --link mysql:mysql -p 8000:80 -d wordpress

Here is my Docker-compose file
web:
image: wordpress
links:

  • mysql
    environment:
  • WORDPRESS_DB_PASSWORD=dbron
    ports:
  • “127.0.0.3:8080:80”
    mysql:
    image: mysql:5.7
    environment:
  • MYSQL_ROOT_PASSWORD=mysqlron
  • MYSQL_DATABASE=my-wpdb

Here are part of the messages
2020-03-28 07:58:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10
mysql_1 | 2020-03-28T07:58:05.242057Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: daf49295-70c9-11ea-815e-0242ac110002.
mysql_1 | 2020-03-28T07:58:05.246546Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.

mysql_1 | 2020-03-28T07:58:07.413963Z 0 [Warning] CA certificate ca.pem is self signed.
mysql_1 | 2020-03-28T07:58:08.162512Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
web_1 | [28-Mar-2020 07:58:08 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
web_1 |
web_1 | MySQL Connection Error: (2002) Connection refused
web_1 |
web_1 | MySQL Connection Error: (2002) Connection refused

2020-03-28T07:58:12.137291Z 0 [Note] mysqld (mysqld 5.7.29) starting as process 78 .

v2020-03-28T07:58:20.194431Z 0 [Note] mysqld: ready for connections.
mysql_1 | Version: ‘5.7.29’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
mysql_1 | 2020-03-28T07:58:20.481226Z 2 [Note]
web_1 | [28-Mar-2020 07:58:20 UTC] PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user ‘root’@‘172.17.0.3’ (using password: YES) in Standard input code on line 22