从环境变量循环获取 - name: "discovery.zen.minimum_master_nodes" value: "2" 带点类型的环境变量然后再放入数组 最后执行命令作为参数 另一种env的处理方法是启动容器后执行脚本 声明新变量赋值环境变量的值 sed 替换变量到 配置文件
$ cat bin/es-docker #!/bin/bash declare -a es_opts while IFS='=' read -r envvar_key envvar_value do # Elasticsearch env vars need to have at least two dot separated lowercase words, e.g. `cluster.name` if [[ "$envvar_key" =~ ^[a-z_]+\.[a-z_]+ ]] then if [[ ! -z $envvar_value ]]; then es_opt="-E${envvar_key}=${envvar_value}" es_opts+=("${es_opt}") fi fi done < <(env) export ES_JAVA_OPTS="-Des.cgroups.hierarchy.override=/ $ES_JAVA_OPTS" exec bin/elasticsearch "${es_opts[@]}"
时来天地皆同力,运去英雄不自由