如何将使用spring-boot-maven-plugin env构建的Docker映像从POSIX更改为C.UTF-8

s4n0splo  于 2023-01-30  发布在  Spring
关注(0)|答案(1)|浏览(170)

当我构建映像并从容器检查locale

mvn spring-boot:build-image
docker run myimage
docker exec -it <id> locale

我得到了

LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

我的应用程序在处理非ASCII字符串时失败

java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: ...
at java.base/sun.nio.fs.UnixPath.encode(Unknown Source)
at java.base/sun.nio.fs.UnixPath.(Unknown Source)
at java.base/sun.nio.fs.UnixFileSystem.getPath(Unknown Source)
at java.base/java.nio.file.Path.resolve(Unknown Source)

UTF-8字符集修复错误

docker run -e LANG=C.UTF-8 myimage

我想把LANG env默认值添加到图像中。我该怎么做?

dm7nw8vv

dm7nw8vv1#

配置

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <image>
            <env>
                <BPE_LANG>C.UTF-8</BPE_LANG>
            </env>
        </image>
    </configuration>
</plugin>

修复了docker exec -it <id> locale显示POSIX的问题。
这是我的建议,我对你感激不尽!

相关问题