If you want to use grumphp together with git hooks, the grumphp commands need to be executed inside the phpfpm container. To configure that, do the following:
Copy provided grumphp templates into your project
cp magento2-dockergento/config/grumphp/hooks <your_project>/config/grumphp/hooks
Add this in your composer.json:
"scripts": {
"grumphpTemplates": "cp -Rf config/grumphp/hooks/* vendor/phpro/grumphp/resources/hooks/local/",
"pre-autoload-dump": [
"cp vendor/magento/magento2-base/app/etc/NonComposerComponentRegistration.php app/etc/NonComposerComponentRegistration.php"
],
"post-install-cmd": [
"@grumphpTemplates"
],
"post-update-cmd": [
"@grumphpTemplates"
]
}