r/PHPhelp • u/thmsbrss • Oct 25 '25
Solved Wolfi OS / PHP Docker Images / Unable to load dynamic library
Has anyone experiences with PHP Docker Images based on Wolfi OS?
I have the following minimal Dockerfile:
FROM cgr.dev/chainguard/wolfi-base:latest
RUN <<EOF
apk update
apk add --no-cache \
php-8.4 \
php-8.4-pdo \
php-8.4-pdo_mysql
EOF
EXPOSE 8888
CMD ["php", "-S", "0.0.0.0:8888", "-t", "/app"]When running it with a simple `index.php` displaying nothing but PHP info:
docker run --rm -v .:/app -p 8888:8888 php:8.4-wolfi php -S 0.0.0.0:8888 -t /appI get the following PHP Warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/modules/pdo_mysql.so (/usr/lib/php/modules/pdo_mysql.so: undefined symbol: mysqlnd_get_client_info), /usr/lib/php/modules/pdo_mysql.so.so (/usr/lib/php/modules/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0The relevant info from the PHP warning is: "cannot open shared object file".
Any idea to solve this?
~~~
Edit: The problem is fixed for PHP 8.4. But if I take the same config for PHP 8.2 or PHP 8.3, I get similar Warnings.
PHP Startup: Unable to load dynamic library 'openssl.so' (tried: /usr/lib/php/modules/openssl.so (/usr/lib/php/modules/openssl.so: undefined symbol: zend_argument_must_not_be_empty_error), /usr/lib/php/modules/openssl.so.so (/usr/lib/php/modules/openssl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /usr/lib/php/modules/mbstring.so (/usr/lib/php/modules/mbstring.so: undefined symbol: zend_ini_str), /usr/lib/php/modules/mbstring.so.so (/usr/lib/php/modules/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'phar.so' (tried: /usr/lib/php/modules/phar.so (/usr/lib/php/modules/phar.so: undefined symbol: zend_declare_typed_class_constant), /usr/lib/php/modules/phar.so.so (/usr/lib/php/modules/phar.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
1
Upvotes
1
u/thmsbrss Oct 26 '25 edited Oct 26 '25
Okay, I was able to resolve the issue. Depending on the version, there appear to be some unclear inner dependencies in PHP.
This image now works for PHP versions 8.2, 8.3, and 8.4.
Or see my try-out here: https://github.com/tbreuss/php-web-server/tree/chainguard-wolfi-base
1
u/obstreperous_troll Oct 25 '25
Most alpine PHP packages are of the form
php84-pdo_mysql, so I don't know what you're grabbing there. You probably needphp84-mysqlndas well.1
u/ElectronicOutcome291 Oct 25 '25
Does the File exist in the Container? Check Container $LD_LIBRARY_PATH