Hello. New to docker and the forum. I did a lot of digging and found people with similar issues to mine, but could not come up with an solid resolution for my case. I have a rather simple setup with two containers, one for my app, and one for my mysql database. I am using Docker 1.10.2 and docker-compose 1.6.0.
symfony: build: symfony/ ports: - "8081:8081" command: php -S 0.0.0.0:8081 -t web volumes: - ./symfony/trunk:/var/www links: - mysql mysql: image: mysql:5.6 ports: - "32795:3306" environment: MYSQL_ROOT_PASSWORD: some-root-password MYSQL_DATABASE: some-database volumes: - ./symfony/data:/docker-entrypoint-initdb.d
While the symfony container has it’s own Dockerfile, the mysql container does not, it just uses the standard mysql image. I can build and bring up the containers just fine with: docker-compose up -d
The application is running and accessible on port 8081. I can even log into the mysql database from the HOST machine with: mysql -u root -psome-root-password -h 0.0.0.0 -P 32795 some-database
The .sql file I put in symfony/data/ is loading. All is peachy keen. Except, my application cannot connect to the mysql database. Also, if I initiate a shell session on the mysql container (docker run -it mysql /bin/bash) I am unable to log into the database directly with: mysql -u root -psome-root-password -h 0.0.0.0
I’ve tried using “0.0.0.0” and “localhost” with port 3306 from within the shell session and within my application’s configuration, and neither work. Both the application and shell command give the oh-so-familiar errors:
# Using "0.0.0.0" SQLSTATE[HY000]  Can't connect to MySQL server on '0.0.0.0' (111) # Using "localhost" SQLSTATE[HY000]  Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I am guessing that I am making some very simply noob mistake, but would be very grateful for any insight the community could offer. Thanks in advance.
For what it’s worth, there are no suspicious warnings/errors in the docker logs output for the mysql container. Additionally, when I access the mysql container with /bin/bash, I get the errors above when trying to connect immediately. If, however, I run /etc/init.d/mysql start, the mysql daemon will spin up, and i am then able to log in via: mysql -u admin