环境介绍:
docker镜像、alpine系统、hyperf框架、使用阿里云Oss的sdk上传文件
报错记录:
PHP Notice: iconv(): Wrong charset, conversion from `GBK' to `UTF-8//IGNORE' is not allowed in /opt/www/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php on line 3076
Notice: iconv(): Wrong charset, conversion from `GBK' to `UTF-8//IGNORE' is not allowed in /opt/www/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php on line 3076
原因:
docker-library/php#240 如果使用了alpine系统,libiconv的版本会很低,需要更新一下 libiconv的版本
解决方案
在dockerfile中添加如下命令更新
RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
重新打包镜像,问题解决。