How to fix docker MariaDB “mysql”: executable file not found in $PATH: unknown

Problem:

You want to run a mysql command in a MariaDB docker container such as

docker-compose exec -T mariadb mysql -uroot -p${MARIADB_ROOT_PASSWORD} mydatabase < dump.sql

but you see the following error message:

OCI runtime exec failed: exec failed: unable to start container process: exec: "mysql": executable file not found in $PATH: unknown

Solution:

For newer MariaDB container versions, the mysql executable does not exist any more. Replace mysql with mariadb to fix the issue, for example:

docker-compose exec -T mariadb mariadb -uroot -p${MARIADB_ROOT_PASSWORD} mydatabase < dump.sql