I am trying to run WordPress on docker with mysql installed on my local host machine (ubuntu 14.04)
I am using the docker image from here: https://registry.hub.docker.com/_/wordpress/
I passed my host ip address (192.168.1.1) and the port (3306) as shown below
sudo docker run -it --name wp -e WORDPRESS_DB_HOST=192.168.1.1:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=root -d wordpress
but I am getting the following error, when I try to run the image
"MySQL Connection Error: (2002) Connection refused"
Below are the exact steps, I follow
sudo docker run -it --name wp -e WORDPRESS_DB_HOST=192.168.1.1:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=root -d wordpress
sudo docker ps -a
sudo docker commit <container_id> myuser/eslwp
sudo docker images
sudo docker run -i -t myuser/eslwp
I think Adrian is right, verify if your mysql allow remote connection for
root
. You can check out this post to troubleshoot.Other then that, it might be your firewall blocking the connection.
Also you don’t need the
-e WORDPRESS_DB_USER=root
parameter when using the root user.