问题描述:
打包的docker镜像,启动时使用docker run -e 参数添加环境变量时,环境变量名称中包含".",有时能在环境变量里获取到,有时不能在环境变量里获取到;
由于linux设置环境变量的规范中,不允许带".",但公司老的内部java框架中使用了读取带"."的环境变量做配置,所以需要解决该问题;
复现方法:
先打包基础的docker镜像:
Dockerfile如下
FROM openjdk:8u151-jdk
MAINTAINER Ma Qian<maqian258@gmail.com>
RUN curl -sSL 'https://raw.githubusercontent.com/maqian/toolbox/master/debian/stretch/set-sources-cn' | sh \
&& curl -sSL 'https://raw.githubusercontent.com/maqian/toolbox/master/debian/set-timezone-cn' | sh \
&& curl -sSL 'https://raw.githubusercontent.com/maqian/toolbox/master/debian/set-locale-cn' | sh \
&& curl -sSL 'https://raw.githubusercontent.com/maqian/toolbox/master/sysfree/install-ejava' | sh \
&& apt-get install -y openjdk-8-dbg
ENV TIMEZONE=Asia/Shanghai TZ=Asia/Shanghai \
LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8:zh:en_US:en
dockerfile目录下,执行docker build -t hub.wen