Apm-server.yml using environment variable

Kibana version: 7.4.2

Elasticsearch version : 7.4.2

APM Server version: apm-server-oss:7.2.1

I'm trying to create a container apm-server but when I try to use environment variable as this https://www.elastic.co/guide/en/apm/server/current/using-environ-vars.html and I've tried this as well [${ES_HOST:? "http://localhost:9200"}]

it return an error
2020-05-18T20:52:17.956Z INFO instance/beat.go:292 Setup Beat: apm-server; Version: 7.2.1
2020-05-18T20:52:17.957Z INFO instance/beat.go:385 apm-server stopped.
2020-05-18T20:52:17.957Z ERROR instance/beat.go:877 Exiting: error initializing publisher: missing field accessin

this is my docker file


FROM docker.elastic.co/apm/apm-server-oss:7.2.1
COPY apm-server.yml /usr/share/apm-server/apm-server.yml
USER root
RUN export ES_HOSTS="host:443"
RUN chown apm-server /usr/share/apm-server/apm-server.yml
RUN chmod go-w /usr/share/apm-server/apm-server.yml
USER  apm-server

this is my apm-server.yml

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  hosts: '${ES_HOSTS}'

Will only export that environment variable for the duration of that RUN, it is not still set when the container runs.

Try ENV instead like:

ENV ES_HOSTS="host:443" or better yet, set the environment variable when starting the container.

Thanks a lot for your help