Docker Community Forums

Share and learn in the Docker community.

Environment variable not processed

I’m trying to run an elasticsearch docker container passing the following environment variable, which is required in my case.

docker run -e “discovery.type=single-node” some_path/Elasticsearch:1.2.3

It fails as follows because the environment variable is not processed.

ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of  [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

I’ve seen chatter about similar but no useful resolution. I’d appreciate if anyone has ideas on the matter.

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Version:      3.2.3
API Version:  3.2.3
Go Version:   go1.15.14
Built:        Thu Sep 23 23:03:03 2021
OS/Arch:      linux/amd64

You actually run a Podman container not Docker container. Podman is not Docker. It has a compatible interface with Docker and you can use Docker images but that’s all. I just wanted to clarify that although I don’t think that is the problem here.

I tried the official elasticsearch image and it works even without setting the discovery type. Can you tell more about what kind of image you are using? How elastic search runs in the container? Directly as PID 1 or started with supervisor?

True, docker or podman makes no difference in this case.

Sorry, I should have clarified, I built RPM derived from GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine etc.

My Dockerfile:

FROM X/linux:8
COPY rpms /tmp/
RUN dnf install -y /tmp/*.rpm &&\
    dnf update -y systemd systemd-libs &&\
    dnf clean all &&\
    rm -rf /var/cache/yum/* /tmp/*.rpm

RUN dnf install -y libX11 libXext libXi libXrender libXtst alsa-lib &&\
    getent group elasticsearch >/dev/null || /usr/sbin/groupadd -r elasticsearch &&\
    getent passwd elasticsearch >/dev/null || /usr/sbin/useradd -r -g elasticsearch -d /var/lib/elasticsearch -s /usr/sbin/nologin \
        -c "Elastic Search shared service user" elasticsearch

RUN chmod -R 0755 /var/log/elasticsearch /var/lib/elasticsearch /etc/elasticsearch /usr/share/elasticsearch &&\
    chown -R elasticsearch:elasticsearch /var/log/elasticsearch /var/lib/elasticsearch /etc/elasticsearch /usr/share/elasticsearch &&\
    chmod +x /usr/bin/

ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/share/elasticsearch/bin:/usr/share/elasticsearch/jdk/bin"
ENV LD_LIBRARY_PATH="/usr/share/elasticsearch/jdk/lib:/usr/share/elasticsearch/jdk/lib/server"

EXPOSE 9200 9300
USER elasticsearch
ENTRYPOINT  [ "/usr/share/elasticsearch/bin/"]

I’m unsure how/where environment variable is processed when passed from shell; is there an oversight in my Dockerfile?

If I include the variable in elasticsearch.yml file and then build etc. all is good.

I worked with an ElasticSearch container which couldn’t use the environment variables. I couldn’t figure out why so I created a script which regenerated the configuration file and restarted Elasticsearch. It was a nasty solution it was acceptable in my case. I don’t know what causes your problem but the official elasticsearch works well, so you could try to compare yours and the official version.