Why not using mysql in docker too? first, I just beginner in this container/docker thing, so I don’t know how reliable docker volumes. For safer/easier way, I use direct sql installation in host. But how if you container want to access your sql, here is how to do it

  1. Check your container IP address using docker inspect your-container-name |grep IPAdress

    Check Container IP Address

    Check Container IP Address

  2. Create sql user in your local sql

    Create a New User for Your Container Only

    Create a New User for Your Container Only

  3. Don’t forget to allow container IP Address in your firewall.

    Allow IP in UFW

    Allow IP in UFW

To check sql connection between container & host, you can install mysql-client at container & try connect to host mysql