The MySQL connection is refused running Docker Wordpress on a CentOS 6.6 machine. The MySQL server is running on the same machine as Docker. I have a MySQL wordpress user with full privs on the wordpress database from any host and have confirmed that I can connect to the account from the command line. Docker run -it -name blog -e WORDPRESSDBHOST=127.0.0.1:3306 -e WORDPRESSDBUSER=wordpress -e WORDPRESSDBPASSWORD=.p 9009:80 wordpress:latest WordPress not found in /var/www/html - copying now.
WARNING: /var/www/html is not empty - press Ctrl+C now if this is an error! + ls -A index.html + sleep 10 Complete! WordPress has been successfully copied to /var/www/html Warning: mysqli::mysqli: (HY000/2002): Connection refused in - on line 10 MySQL Connection Error: (2002) Connection refused Warning: mysqli::mysqli: (HY000/2002): Connection refused in - on line 10 MySQL Connection Error: (2002) Connection refused.
Yes, when I replaced 127.0.0.1 with the machine's actual IP it connects, but now the MySQL connection times out. I'm guessing that's because of the firewall we have on the host's 3306 port. In my case, for a variety of reasons, I'm not running MySQL in a container, nor do I wish to. MySQL is running on the same host as Docker.
Phpmyadmin: image: corbinu/docker-phpmyadmin links: - wordpress_db:mysql ports: - 8181:80 environment: MYSQL_USERNAME: root MYSQL_ROOT_PASSWORD: examplepass. Be sure to replace examplepass with the exact same root password from the wordpress_db container you setup earlier.
I read up on Docker container networking and it seems that I should have -net=host set in the run command. My understanding is that this essentially de-containerizes networking such that 127.0.0.1:3306 in the container maps to port 3306 on the host. That plus a change to the host's firewall to allow connections on 127.0.0.1:3306 got it working. Thanks for the reply.