title: Docker MariaDb - remote access
body: <p>I'm trying to set up remote access to MariaDb via Traefik:</p>
  
  <p>MariaDB docker-compose.yml</p>
  
  <pre><code>version: "2"
  
  services:
    jpz-mariadb:
      image: mariadb:latest
      environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=database
        - MYSQL_USER=user
        - MYSQL_PASSWORD=pass
      networks:
        - web
      volumes:
        - ./db:/docker-entrypoint-initdb.d
        - jpz-mariadb:/var/lib/mysql:nocopy # I want to manage volumes manually.
      labels:
        - 'traefik.backend=jpz-mariadb'
        - 'traefik.frontend.rule=Host:mariadb.localtest.me'
  
    jpz-pma:
      image: phpmyadmin/phpmyadmin
      environment:
        PMA_HOST: jpz-mariadb
        PHP_UPLOAD_MAX_FILESIZE: 1G
        PHP_MAX_INPUT_VARS: 1G
      networks:
        - web
      labels:
        - 'traefik.backend=jpz-pma'
        - 'traefik.frontend.rule=Host:pma.localtest.me'
  
  volumes:
    jpz-mariadb:
      external: true
  
  networks:
    web:
      external:
        name: traefik_webgateway
  </code></pre>
  
  <p>And Traefik docker-compose.yml</p>
  
  <pre><code>version: '2'
  
  services:
    proxy:
      image: traefik
      command: --web --docker --docker.domain=localtest.me --logLevel=DEBUG
      networks:
        - webgateway
      ports:
        - "81:80"
        - "3307:3306"
        - "443:443"
        - "8081:8080"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /dev/null:/traefik.toml
  
  networks:
    webgateway:
      driver: bridge
  </code></pre>
  
  <p>I'm not able to connect to mariadb.localtest.me:3307 via <code>mysql -u root -p -h mariadb.localtest.me -P 3307</code></p>
  
  <p>Getting:</p>
  
  <blockquote>
    <p>Lost connection to MySQL server at 'reading initial communication packet', system error: 0 (Mysql2::Error)</p>
  </blockquote>
  
  <p>How to fix it?</p>
  
  <p>Thanks</p>