[why] when build logging-es images in x86 machine, error message: libcontainer: container start initialization failed: standard_init_linux.go:220: exec user process caused "exec format error" The command '/bin/sh -c sed -i 's:#network.host: _site_:network.host: 0.0.0.0:' /usr/share/elasticsearch/config/elasticsearch.yml && sed -i '$a path.data: /srv/es/logging-es' /usr/share/elasticsearch/config/elasticsearch.yml && sed -i '$a node.name: node-1' /usr/share/elasticsearch/config/elasticsearch.yml && sed -i '$a cluster.initial_master_nodes: ["node-1"]' /usr/share/elasticsearch/config/elasticsearch.yml && sed -i '$a indices.memory.index_buffer_size: 20%' /usr/share/elasticsearch/config/elasticsearch.yml && sed -i '$a thread_pool.write.queue_size: 2000' /usr/share/elasticsearch/config/elasticsearch.yml && sed -i "s/-Xms1g/-Xms30g/g" /usr/share/elasticsearch/config/jvm.options && sed -i "s/-Xmx1g/-Xmx30g/g" /usr/share/elasticsearch/config/jvm.options' returned a non-zero code: 1
because arm base image not support to build in x86 machine.
[how] 1. use images dict to store arm and x86 base images 2. use $(arch) to choose base image according to different system architecture In addition, 'declare', arrays, arrays references are undefined in POSIX sh by shellcheck, so change '#!/bin/sh' to '#!/bin/bash'.
Signed-off-by: Liu Yinsi liuyinsi@163.com --- container/logging-es/Dockerfile | 3 ++- container/logging-es/build | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/container/logging-es/Dockerfile b/container/logging-es/Dockerfile index 707299f..6c01c43 100644 --- a/container/logging-es/Dockerfile +++ b/container/logging-es/Dockerfile @@ -1,7 +1,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
-FROM gagara/elasticsearch-oss-arm64:7.6.2 +ARG BASE_IMAGE +FROM $BASE_IMAGE
# docker image borrowed from hub.docker.com/r/gagara/elasticsearch-oss-arm64
diff --git a/container/logging-es/build b/container/logging-es/build index 0ddecbf..451041b 100755 --- a/container/logging-es/build +++ b/container/logging-es/build @@ -1,5 +1,14 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
-docker build -t logging-es:7.6.2 . +declare -A BASE_IMAGE_DICT + +BASE_IMAGE_DICT=( + ["aarch64"]="gagara/elasticsearch-oss-arm64:7.6.2" + ["x86_64"]="elasticsearch:7.6.2" +) + +BASE_IMAGE=${BASE_IMAGE_DICT[$(arch)]} + +docker build -t logging-es:7.6.2 --build-arg BASE_IMAGE="$BASE_IMAGE" .