I've got a Symfony2 application in a docker project, using docker-compose.
I get the following error when trying to run schema updates to my database.
[Doctrine\DBAL\Exception\DriverException]
An exception occured in driver: SQLSTATE[HY000] [1130] Host '172.17.0.129' is not allowed to connect to this MySQL server
My docker-compose.yml file:
api:
build: images/nginx
ports:
- "80:80"
- "9000:9000"
links:
- mysql:mysql
- memcached:memcached
- redis:redis
- elasticsearch:elasticsearch
- rabbitmq:rabbitmq
volumes:
- www/api:/var/www
- sites/api:/etc/nginx/sites-enabled
socketserver:
build: images/socketserver
links:
- rabbitmq:rabbitmq
ports:
- "5000:5000"
volumes:
- www/socketserver:/var/www
- sites/socketserver:/etc/nginx/sites-enabled
adminpanel:
build: images/adminpanel
ports:
- "8001:8001"
volumes:
- www/adminpanel:/var/www
- sites/adminpanel:/etc/nginx/sites-enabled
mysql:
image: mysql:latest
expose:
- "3306"
ports:
- "3307:3306"
environment:
MYSQL_DATABASE: api
MYSQL_USER: root
MYSQL_PASSWORD: [REDACTED]
MYSQL_ROOT_PASSWORD: [REDACTED]
memcached:
image: tutum/memcached
ports:
- "11211:11211"
dns: 3.3.3.3
environment:
MEMCACHED_PASS: [REDACTED]
redis:
image: tutum/redis
ports:
- "6379:6379"
dns: 4.4.4.4
environment:
REDIS_PASS: [REDACTED]
elasticsearch:
image: tutum/elasticsearch
ports:
- "9200:9200"
dns: 5.5.5.5
environment:
ELASTICSEARCH_USER:[REDACTED]
ELASTICSEARCH_PASS:[REDACTED]
rabbitmq:
image: dockerfile/rabbitmq
dns: 6.6.6.6
ports:
- "5672:5672"
- "15672:15672"
My Symfony2 parameters.yml:
parameters:
secret: [REDACTED]
locale: en
mailer_transport: smtp
mailer_host: [REDACTED]
mailer_user: test@theladbible.com
mailer_password: [REDACTED]
database_driver: pdo_mysql
database_host: mysql
database_port: 3306
database_name: api
database_user: root
database_password: [REDACTED]
jms_serializer.cache_naming_strategy.class: JMS\Serializer\Naming\IdenticalPropertyNamingStrategy
I've tried multiple different ways. I can't connect via localhost or 127.0.0.1. Putting 'mysql' seemed to link to the database containers correct database address, but then I still get that error shown above.
I'm new to Docker, so I've probably misunderstood some of the fundamentals, apologies if that's the case.
I suspect I need to add the correct user permissions in perhaps? I haven't been able to connect to the database container directly to do this either.
Thanks in advance!