docker wordpress container can't connect to mysql container
I'm at a loss here as to not only why this isn't working but how to further troubleshoot it. I'm new to docker, so could be something obvious, but I can't find it. I did look over some other links here which could be considered "duplicate questions" and nothing helped.
My playground setup:
mysql container named: "db"
phpmyadmin container named: phpmyadmin
wordpress container named: domain-blog
All containers are in a bridge network docker0
At this stage I'm starting all containers individually, but I am ensuring the database is up and running prior to running wordpress.
The string to start the wordpress container:
docker run --name="domain-blog" -d \ -e WORDPRESS_DB_HOST=db:3306 \ -e WORDPRESS_DB_USER=domain_user \ -e WORDPRESS_DB_PASSWORD=testedpassword \ -e WORDPRESS_DB_NAME=domain_blog \ -e WORDPRESS_TABLE_PREFIX=astring \ --network=docker0 \ -p 8081:80 \ --restart always \ wordpress
What I've tried:
- I can log in as
rootpasswordfrom phpmyadmin navigating via
- I can log in as
domain_user, using the
- Confirmed I can add a new table when logged in as domain_user.
- I have spun up an ubuntu container and installed network tools, can ping all containers.
- I installed
iputils-pingdirectly on the wordpress container and can ping
ping db. Ping is hitting, but also confirmed that the db is resolving to the correct ip address.
cat wp-config.phpshows that user, host(db:3306), password, and database are all being passed through as I'd expect.
I used phpmyadmin when I created the new user/password, database, and added permissions for the user to that database. The user is set to log in from
The error I'm getting on not being able to access the database is when trying to navigate to the blog via
hostip:8081 Exact error:
Error establishing a database connection