I dug around again, and I think I've identified the root cause of the issue. Thanks to @hakre :)
If you run the command apk add composer
, additional packages will be installed alongside composer (presumably as dependencies).
apk add --no-cache composer
(1/15) Installing php83-common (8.3.15-r0)
(2/15) Installing libedit (20240808.3.1-r0)
(3/15) Installing pcre2 (10.43-r0)
(4/15) Installing php83 (8.3.15-r0)
(5/15) Installing php83-phar (8.3.15-r0)
(6/15) Installing php83-curl (8.3.15-r0)
(7/15) Installing php83-iconv (8.3.15-r0)
(8/15) Installing php83-mbstring (8.3.15-r0)
(9/15) Installing php83-openssl (8.3.15-r0)
(10/15) Installing libbz2 (1.0.8-r6)
(11/15) Installing libzip (1.11.2-r0)
(12/15) Installing php83-zip (8.3.15-r0)
(13/15) Installing libstdc++ (14.2.0-r4)
(14/15) Installing 7zip (24.08-r0)
(15/15) Installing composer (2.8.4-r0)
I'm not sure what exactly happens after these packages are installed, but it somehow affects how the newly installed composer sees the path to the php interpreter.
The PHP binary path, which provides by the php:8.3-fpm-alpine image, looks like this: /usr/local/bin/php
.
-rwxr-xr-x 1 root root /usr/local/bin/php
But the installed composer now looks at the new PHP binary path, (the newly installed php83 package): /usr/bin/php83
.
-rwxr-xr-x 1 root root /usr/bin/php83