alpine 镜像 java 日志中文问号乱码
使用alpine镜像时,在dockerfile中修改语言环境
dockerfile如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16FROM alpine:3.6
# Install language pack
RUN apk --no-cache add ca-certificates wget && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-bin-2.25-r0.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-i18n-2.25-r0.apk && \
apk add glibc-bin-2.25-r0.apk glibc-i18n-2.25-r0.apk glibc-2.25-r0.apk
COPY ./locale.md /locale.md
RUN cat locale.md | xargs -i /usr/glibc-compat/bin/localedef -i {} -f UTF-8 {}.UTF-8
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8同级目录下创建 locale.md 文件,将以下内容拷贝入 locale.md:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261aa_DJ
aa_ER
aa_ET
af_ZA
am_ET
an_ES
ar_AE
ar_BH
ar_DZ
ar_EG
ar_IN
ar_IQ
ar_JO
ar_KW
ar_LB
ar_LY
ar_MA
ar_OM
ar_QA
ar_SA
ar_SD
ar_SY
ar_TN
ar_YE
as_IN
ast_ES
ayc_PE
az_AZ
be_BY
bem_ZM
ber_DZ
ber_MA
bg_BG
bho_IN
bn_BD
bn_IN
bo_CN
bo_IN
br_FR
brx_IN
bs_BA
byn_ER
ca_AD
ca_ES
ca_FR
ca_IT
crh_UA
csb_PL
cs_CZ
cv_RU
cy_GB
da_DK
de_AT
de_BE
de_CH
de_DE
de_LU
doi_IN
dv_MV
dz_BT
el_CY
el_GR
en_AG
en_AU
en_BW
en_CA
en_DK
en_GB
en_HK
en_IE
en_IN
en_NG
en_NZ
en_PH
en_SG
en_US
en_ZA
en_ZM
en_ZW
es_AR
es_BO
es_CL
es_CO
es_CR
es_CU
es_DO
es_EC
es_ES
es_GT
es_HN
es_MX
es_NI
es_PA
es_PE
es_PR
es_PY
es_SV
es_US
es_UY
es_VE
et_EE
eu_ES
fa_IR
ff_SN
fi_FI
fil_PH
fo_FO
fr_BE
fr_CA
fr_CH
fr_FR
fr_LU
fur_IT
fy_DE
fy_NL
ga_IE
gd_GB
gez_ER
gez_ET
gl_ES
gu_IN
gv_GB
ha_NG
he_IL
hi_IN
hne_IN
hr_HR
hsb_DE
ht_HT
hu_HU
hy_AM
ia_FR
id_ID
ig_NG
ik_CA
is_IS
it_CH
it_IT
iu_CA
ja_JP
ka_GE
kk_KZ
kl_GL
km_KH
kn_IN
kok_IN
ko_KR
ks_IN
ku_TR
kw_GB
ky_KG
lb_LU
lg_UG
li_BE
lij_IT
li_NL
lo_LA
lt_LT
lv_LV
mag_IN
mai_IN
mg_MG
mhr_RU
mi_NZ
mk_MK
ml_IN
mni_IN
mn_MN
mr_IN
ms_MY
mt_MT
my_MM
nb_NO
nds_DE
nds_NL
ne_NP
nhn_MX
niu_NU
niu_NZ
nl_AW
nl_BE
nl_NL
nn_NO
nr_ZA
nso_ZA
oc_FR
om_ET
om_KE
or_IN
os_RU
pa_IN
pa_PK
pl_PL
ps_AF
pt_BR
pt_PT
ro_RO
ru_RU
ru_UA
rw_RW
sa_IN
sat_IN
sc_IT
sd_IN
se_NO
shs_CA
sid_ET
si_LK
sk_SK
sl_SI
so_DJ
so_ET
so_KE
so_SO
sq_AL
sq_MK
sr_ME
sr_RS
ss_ZA
st_ZA
sv_FI
sv_SE
sw_KE
sw_TZ
szl_PL
ta_IN
ta_LK
te_IN
tg_TJ
th_TH
ti_ER
ti_ET
tig_ER
tk_TM
tl_PH
tn_ZA
tr_CY
tr_TR
ts_ZA
tt_RU
ug_CN
uk_UA
unm_US
ur_IN
ur_PK
uz_UZ
ve_ZA
vi_VN
wa_BE
wae_CH
wal_ET
wo_SN
xh_ZA
yi_US
yo_NG
yue_HK
zh_CN
zh_HK
zh_SG
zh_TW
zu_ZA构建环境
1
docker build -t utf8-alpine .
运行构建的镜像,查看编码环境
1
2
3# docker run -it --rm utf8-alpine sh
# env #查看环境变量
# /usr/glibc-compat/bin/locale -a
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!