cannot use some drush commands
I prefer to use drush from drush alias files, so that the magic of Drush figuring out everything from the document root isn't so magical and you can sometimes more easily debug issues from a proper drush alias file.

As others mention it's likely the database connection that's not working. In docker you can use the --add-host build option, or the extra_hosts docker-compose options to give a name to your database container (docker can use the container name to properly create the /etc/hosts entry at runtime).

See this stackexchange answer https://stackoverflow.com/a/38306666/1491507

By following the above directions in docker-compose an entry such as the following that creates a named hosted in /etc/hosts as my_resolved_db_service which is magically resolved to the mariadb container.

extra_hosts:
  - "my_resolved_db_service:mariadb"


Then in a drush alias file, or when installing drupal via drush you would use the /etc/host name created:
drush si --db-url=mysql://root:root@my_resolved_db_service/drupal as an example.