Expected Behavior
Assuming a Compose service app using this Docker image and phpstan/phpstan is installed via Composer, running its binary vendor/bin/phpstan should work without the path prefix vendor/bin:
± docker compose exec app phpstan
Note: Using configuration file /var/www/html/phpstan.neon.
453/453 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[OK] No errors
Current Behavior
Trying to run a Composer binary without path fails:
± docker compose exec app phpstan
OCI runtime exec failed: exec failed: unable to start container process: exec: "phpstan": cannot run executable found relative to current directory: unknown
This seems to be related to Go 1.19 which dropped support for executing commands from the current directory (a "dot path") as a security measurement. Obviously the Docker engine did upgrade to this Go version in the meantime.
This Docker image adds (among others) vendor/bin to the $PATH which did allow for running Composer binaries so far but this has stopped working now:
https://github.com/thecodingmachine/docker-images-php/blob/098c31b33f019fb69f45df85a14f507a4f300fb5/utils/Dockerfile.slim.blueprint#L255L262
Possible Solution
Use absolute paths in the $PATH, so /var/www/html/vendor/bin and /usr/src/app/vendor/bin instead of just vendor/bin depending on CLI/FPM/Apache variant.
Steps to Reproduce (for bugs)
- Have a recent Docker engine (23.0 or newer)
- Install a Composer package which provides a binary
- Use Docker Compose or Docker
exec to run that binary just by its name
- See the error mentioned above
Context
Developing PHP-based apps. ;-)
Your Environment
- Version used: 8.1-v4-fpm-node16
- Operating System and version: Debian Sid
- Link to your project: n/a
Expected Behavior
Assuming a Compose service
appusing this Docker image andphpstan/phpstanis installed via Composer, running its binaryvendor/bin/phpstanshould work without the path prefixvendor/bin:Current Behavior
Trying to run a Composer binary without path fails:
This seems to be related to Go 1.19 which dropped support for executing commands from the current directory (a "dot path") as a security measurement. Obviously the Docker engine did upgrade to this Go version in the meantime.
This Docker image adds (among others)
vendor/binto the$PATHwhich did allow for running Composer binaries so far but this has stopped working now:https://github.com/thecodingmachine/docker-images-php/blob/098c31b33f019fb69f45df85a14f507a4f300fb5/utils/Dockerfile.slim.blueprint#L255L262
Possible Solution
Use absolute paths in the
$PATH, so/var/www/html/vendor/binand/usr/src/app/vendor/bininstead of justvendor/bindepending on CLI/FPM/Apache variant.Steps to Reproduce (for bugs)
execto run that binary just by its nameContext
Developing PHP-based apps. ;-)
Your Environment