title: How to connect a Docker container of Grafana to a Docker conatiner of MySql?
body: <p>I wish to set up 2 docker containers: grafana and mysql and to allow queries from the grafana to the mysql db. 
  I have an AWS machine, in which I built the following folders structure:</p>
  
  <pre><code>- docker
    - docker-compose.yml
    - grafana:
      - config.ini
      - dashboards:
        - grafana_dashboard.json
      - provisioning:
        - dashboards:
          - all.yml
        - datasources:
          - all.yml
      - Dockerfile
    - mysql:
      - dbcreation.sql
      - Dockerfile
    - dashboards:
    - import.sh
  </code></pre>
  
  <p>the content of the docker-compose.yml is:</p>
  
  <pre><code>version: '2'
  services:
    db-service:
      build: './mysql'
      container_name: mysql
      restart: always
      ports:
        - "3306:3306"
      networks:
        net:
          ipv4_address: 172.16.1.3
  
    grafana-service:
      build: './grafana'
      container_name: grafana
      restart: always
      ports:
        - "3000:3000"
      environment:
        GF_SECURITY_ADMIN_PASSWORD: "XXX1"
        GF_AUTH_PROXY_ENABLED: "true"
        GF_SECURITY_DATA_SOURCE_PROXY_WHITELIST: 172.16.1.3:3306
        GF_AUTH_ANONYMOUS_ENABLED: "true"
        GF_LOG_LEVEL: "debug"
      depends_on:
        - db-service
      networks:
        net:
          ipv4_address: 172.16.1.4
  
  
  networks:
    net:
      external: true
  
  volumes:
    grafanadata:
      driver: local
    mysqldata:
  </code></pre>
  
  <p>The dockerfile for the grafana:</p>
  
  <pre><code>FROM grafana/grafana:5.2.2
  ADD ./provisioning /etc/grafana/provisioning
  ADD ./dashboards /var/lib/grafana/dashboards
  ENV DS_DB "grafana"
  </code></pre>
  
  <p>The content of the mysql/Dockerfile is:</p>
  
  <pre><code>FROM mysql:8.0.12
  
  ENV MYSQL_ROOT_PASSWORD="XXX2"
  ENV MYSQL_DATABASE="grafana"
  
  ADD ./dbcreation.sql /docker-entrypoint-initdb.d/dbcreation.sql
  EXPOSE 3306
  </code></pre>
  
  <p>The grafana_dashboard.json file has the exported json from the Grafana I had set up locally on my own computer. 
  The dbcreation.sql file has the exported data from the local DB I had set up locally on my own computer. </p>
  
  <p>I'm running the following commands: </p>
  
  <pre><code>docker network create --gateway 172.16.1.1 --subnet 172.16.1.0/24 net
  docker-compose up --build 
  </code></pre>
  
  <p>I'm getting an error: "The authentication plugin is not supported" 
  <a href="https://i.stack.imgur.com/1jHFF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1jHFF.png" alt="The authentication plugin is not supported"></a></p>
  
  <p>when turning the log level of Grafana to debug I'm seeing this: </p>
  
  <pre><code>t=2018-08-19T10:55:20+0000 lvl=dbug msg=getEngine logger=tsdb.mysql connection="root:XXX2@tcp(172.16.1.3:3306)/grafana?collation=utf8mb4_unicode_ci&amp;parseTime=true&amp;loc=UTC&amp;allowNativePasswords=true"
  
  t=2018-08-19T10:55:47+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/tsdb/query status=500 remote_addr=XX.XXX.XXX.XXX time_ms=2 size=195 referer=http://XX.XXX.XXX.XXX:3000/datasources/edit/1
  </code></pre>
  
  <p>I have used the following sources already to set this up: 
  <a href="https://ops.tips/blog/initialize-grafana-with-preconfigured-dashboards/" rel="noreferrer">https://ops.tips/blog/initialize-grafana-with-preconfigured-dashboards/</a></p>
  
  <p><a href="https://storage.pardot.com/138181/61672/mysql_on_docker_how_to_containerize_your_database.pdf" rel="noreferrer">https://storage.pardot.com/138181/61672/mysql_on_docker_how_to_containerize_your_database.pdf</a></p>
  
  <p>Any help would be appreciated! 
  Thanks</p>