Docker - SQLSTATE[HY000] [2002] No such file or directory

I am now running my Docker run just like the example provided AND can prove that I can connect to the MySQL db from within the container. There is nothing special here.

Can you show me an example of yours using Docker?


docker run -d \
  -v /var/invoiceninja/public:/var/app/public \
  -v /var/invoiceninja/storage:/var/app/storage \
  -e APP_ENV='production' \
  -e APP_DEBUG=0 \
  -e APP_URL='http://ninja.dev' \
  -e APP_KEY='base64:Qs7h2EtHleBdaLR+FsAKrBXtDAkzfzPKRfDDgTnxZSA=' \
  -e APP_CIPHER='AES-256-CBC' \
  -e DB_TYPE='mysql' \
  -e DB_STRICT='false' \
  -e DB_HOST='mysql-01.myhost.com' \
  -e DB_DATABASE='ninja' \
  -e DB_USERNAME='ninja' \
  -e DB_PASSWORD='ninja123' \
  -p '9321:9000' \
  invoiceninja/invoiceninja

Connect to MySQL within the container:

ubuntu@ip-172-26-8-7:~$ sudo docker exec -it sharp_lewin /bin/sh
~ $ mysql -h mysql-01.myhost.com -u ninja -pninja123 ninja
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3824725
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [ninja]> show tables
    -> ;
+-----------------+
| Tables_in_ninja |
+-----------------+
| NewTable        |
+-----------------+
1 row in set (0.003 sec)

MySQL [ninja]>