There is a so far merely undocumented installation procedure for Magerun that is extremely handy in project configurations.
You just require Magerun within the Magento project and you can then execute it from the vendor’s bin folder:
$ composer require n98/magerun2 [...]
$ ./vendor/bin/n98-magerun2 --version n98-magerun2 version 1.3.2 by netz98 GmbH
Afterwards if you commit the composer.json and composer.lock files it is a take-away for the whole team.
So it is regardless whether you’re running it locally, inside a docker container or a complete different system. After composer install, n98-magerun2 is available on all target systems.
Just Another Install Example
Here another example I just did with one of our systems that run via docker on my end, but I’m installing on my local system (the folder is mounted inside the docker container):
$ composer require n98/magerun2 --ignore-platform-reqs [...]
The –ignore-platform-reqs switch make composer to install it even despite my local system does not have all Magento2 requirements.