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/docker-entrypoint.sh

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/docker-entrypoint.sh"]

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.

hi! I understand that the answer is a little late, but I faced the same situation and tried to find information in the documentation and forums for a couple of days. In the end, I spat on everything and went to read the scripts of the original container. After 4 hours, after checking the formation of paths and variables several times, I came across an interesting point.
by creating a test script with the contents in the original container, in the /usr/share/elasticsearch/bin directory

source "`dirname "$0"`"/elasticsearch-env
echo $@

and running it, I got a list of variables

having performed this operation in my container, I did not get anything.

I compared the scripts /usr/share/elasticsearch/bin/elasticsearch

and it turned out that when installing from the deb package, we have a hard-coded value of the variable ES_DISTRIBUTION_TYPE=deb, in the original image, the value of this variable = docker, and then there is a check
if [[ “$ES_DISTRIBUTION_TYPE” == “docker” ]]
in which a list of variables is already being generated.
Solution: replace the /usr/share/elasticsearch/bin/elasticsearch script with the original one from the container, or replace the value of the ES_DISTRIBUTION_TYPE variable during assembly

maybe it will be useful to someone in the future

sorry, script /usr/share/elasticsearch/bin/elasticsearch-env