title: Using Docker Compose to connect to mysql running in another container
body: <p>I am new to docker and docker-compose.</p>
  
  <p>I have mysql running in a docker container, with two databases initialized.</p>
  
  <p>I can connect to it using:</p>
  
  <pre><code>mysql --port=3306 -h192.0.0.1 -uroot -ppassword
  </code></pre>
  
  <p>When I run:</p>
  
  <pre><code>docker ps
  
  04bc1d308484        container-mysql   "docker-entrypoint.sh"   2 hours ago         Up 2 hours          3306/tcp            container-mysql
  </code></pre>
  
  <p>My query is that now I want to connect to it from another container using </p>
  
  <pre><code>docker-compose up.
  
  another-image:
    image: another-image
    command: /opt/start.sh
    ports:
      - "8080:8080"
    environment:
      DB_URL: container-mysql
      DB_USER: root
      DB_PASSWORD: password
    external_links:
      - container-mysql
  </code></pre>
  
  <p>Can someone please guide me whats missing and what else is needed.</p>
  
  <p>My container-mysql has two database schema's. </p>
  
  <p>Example:
  firstdb
  seconddb</p>