參考:https://www.clxz.top/2019/05/09/160241/java
本實驗未通過生產環境測試node
[root@node1 tmp]# docker image ls | grep jdk hlwojiv/alpine-jdk8 latest f726e71fd441 5 months ago 237MB [root@node1 tmp]# docker pull hlwojiv/alpine-jdk8
[root@node1 tmp]# docker run -it --rm hlwojiv/alpine-jdk8 /usr/glibc-compat/bin/locale -a | grep zh zh_CN.utf8 zh_HK.utf8 zh_SG.utf8 zh_TW.utf8 [root@node1 tmp]# docker run -it --rm hlwojiv/alpine-jdk8 env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/java/jdk/bin HOSTNAME=ebb732aa197d TERM=xterm LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 JAVA_HOME=/usr/java/jdk HOME=/root
$ git clone https://github.com/hlwojiv/docker-alpine-jdk8.git $ cd docker-alpine-jdk8/ $ ls Dockerfile README.md jre8.tar.gz locale.md $ cat Dockerfile FROM docker.io/jeanblanchard/alpine-glibc MAINTAINER hlwojiv ADD jre8.tar.gz /usr/java/jdk/ RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/main' > /etc/apk/repositories \ && echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/community' >>/etc/apk/repositories \ && apk update && apk add tzdata \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone 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 # Iterate through all locale and install it # Note that locale -a is not available in alpine linux, use `/usr/glibc-compat/bin/locale -a` instead COPY ./locale.md /locale.md RUN cat locale.md | xargs -i /usr/glibc-compat/bin/localedef -i {} -f UTF-8 {}.UTF-8 # Set the lang, you can also specify it as as environment variable through docker-compose.yml ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 ENV JAVA_HOME /usr/java/jdk ENV PATH ${PATH}:${JAVA_HOME}/bin WORKDIR /opt
$ cat locale.md linux
aa_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 iw_IL 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 no_NO nr_ZA nso_ZA oc_FR om_ET om_KE or_IN os_RU pa_IN pap_AN 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
$ docker build -t alpine-utf8-jdk . # 構建報錯,locale.md某些語言報錯 cannot open locale definition file `iw_IL': No such file or directory cannot open locale definition file `no_NO': No such file or directory cannot open locale definition file `pap_AN': No such file or directory
FROM alpine:3.6 # ---not shown here--- # 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 # Iterate through all locale and install it # Note that locale -a is not available in alpine linux, use `/usr/glibc-compat/bin/locale -a` instead COPY ./locale.md /locale.md RUN cat locale.md | xargs -i /usr/glibc-compat/bin/localedef -i {} -f UTF-8 {}.UTF-8 # Set the lang, you can also specify it as as environment variable through docker-compose.yml ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8
刪了一些東西,從新構建git
Dockerfilegithub
FROM docker.io/jeanblanchard/alpine-glibc COPY ./locale.md /locale.md # Install language pack #RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/main' > /etc/apk/repositories \ # && echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/community' >>/etc/apk/repositories \ RUN apk update \ && apk add tzdata \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && apk del tzdata \ && 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 \ https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-bin-2.25-r0.apk \ 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 \ && sleep 3 \ && cat /locale.md | xargs -i /usr/glibc-compat/bin/localedef -i {} -f UTF-8 {}.UTF-8 \ && rm /etc/apk/keys/sgerrand.rsa.pub \ && rm /locale.md \ glibc-2.25-r0.apk \ glibc-bin-2.25-r0.apk \ glibc-i18n-2.25-r0.apk \ && apk del wget ca-certificates\ && rm -rf /var/cache/apk/* \ && rm "/root/.wget-hsts" ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8
locale.mddocker
[root@glowing-bliss-1 tmp]# cat locale.md 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 zh_CN zh_HK zh_SG zh_TW zu_ZA
[root@glowing-bliss-1 tmp]# docker build -t my:v0.6 . [root@glowing-bliss-1 tmp]# docker images | grep v0.6 my v0.6 29a1b86617b0 4 minutes ago 37.7MB
[root@glowing-bliss-1 tmp]# docker run --rm -it my:v0.6 env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=ca966becfb4c TERM=xterm GLIBC_VERSION=2.30-r0 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 HOME=/root failed to resize tty, using default size [root@glowing-bliss-1 tmp]# docker run --rm -it my:v0.6 /usr/glibc-compat/bin/locale -a | grep zh zh_CN.utf8 zh_HK.utf8 zh_SG.utf8 zh_TW.utf8