title: Docker: SQLSTATE[HY000] [2002] No such file or directory
body: <p>Hey guys I'm trying to connect <code>Yii2</code> with <code>mysql</code> running on <code>mariadb</code>.</p>
  
  <p>I'm using docker and I have these containers</p>
  
  <p><code>mariadb</code> and <code>php-fpm</code> I can connect to mysql inside <code>mariadb</code> container using this command <code>mysql -u root -p</code> with no problem.
  also using <code>mysql workbench</code> i can connect to mysql also through tunneling no problem there also.</p>
  
  <p>But when I ran the site eg. mysite.com/user/login, when logging in I get this error</p>
  
  <p><code>SQLSTATE[HY000] [2002] No such file or directory</code>
  <code>Caused by: PDOException</code></p>
  
  <p>this is my <code>mariadb</code> config inside docker-compose file</p>
  
  <pre><code>mariadb:
      image: bitnami/mariadb:latest
      container_name: mariadb
      working_dir: /bitnami/mariadb
      volumes:
          - ./data/mariadb:/bitnami/mariadb
      environment:
          - MARIADB_ROOT_PASSWORD=rootpass
          - MARIADB_DATABASE=mydb
          - MARIADB_USER=david
          - MARIADB_PASSWORD=pass
      ports:
          - "8890:3306"
  </code></pre>
  
  <p>on my <code>main.php</code> config in <code>Yii2</code> I have this as my <code>dsn</code>
  <code>mysql:host=ipvalueofmysite.com;port=8890;dbname=mydb</code></p>