title: Issues connecting a Symfony2 app to a database container in Docker
body: <p>I've got a Symfony2 application in a docker project, using docker-compose. </p>
  
  <p>I get the following error when trying to run schema updates to my database.
  <code>
    [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
  </code></p>
  
  <p>My docker-compose.yml file:</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>My Symfony2 parameters.yml:</p>
  
  <pre><code>  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
  </code></pre>
  
  <p>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. </p>
  
  <p>I'm new to Docker, so I've probably misunderstood some of the fundamentals, apologies if that's the case.</p>
  
  <p>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.</p>
  
  <p>Thanks in advance! </p>