poorman docker stack resolver
docker network inspect --format '{{range $key, $val := .Containers}} {{$key}}|{{$val.IPv4Address}}{{end}}' docker_gwbridge | xargs -d' ' -I{} echo {} | tr "|" " " | xargs -l bash -c 'ip=$1; name=`docker ps --format {{.Names}} -f id=$0`; if [[ ! -z $name ]]; then echo "${name//.*}=${ip//\/*};"; fi' | tee ~/.hosts.env
cis_grafana=172.18.0.6;
cis_influxdb=172.18.0.3;
cis_elastic=172.18.0.4;
cis_fluent=172.18.0.5;
source ~/.hosts.env
curl http://$cis_elastic:9200/_cluster/health?pretty {
"cluster_name" : "xyz-monitoring-cluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 175,
"active_shards" : 175,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 175,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 50.0
}
DOCKER_SERVICES="$(docker network inspect --format '{{range $key, $val := .Containers}} {{$key}}|{{$val.IPv4Address}}{{end}}' docker_gwbridge | xargs -d' ' -I{} echo {} | tr "|" " " | xargs -l bash -c 'ip=$1; name=`docker ps --format {{.Names}} -f id=$0`; if [[ ! -z $name ]]; then echo "${ip//\/*} ${name//.*}\\\n"; fi' |xargs)"
cp /etc/hosts /etc/hosts.docker-pre
sed -n '/#DOCKER_SERVICES_START/{p;:a;N;/#DOCKER_SERVICES_END/!ba;s/.*\n/'"${DOCKER_SERVICES// 1/1}"'/};p' /etc/hosts | tee /etc/hosts.docker
cp /etc/hosts.docker /etc/hosts