0

Hi i'm new to elasticsearch and docker so forgive me if this question is a bit basic.

I want to load up an elasticsearch container (using the official elasticsearch image on dockerhub) with a config file on my host machine

currently what I do is

docker run -d elasticsearch elasticsearch -Des.cluster.name="testcluster1" -Des.node.name="node1" 

and so on.

is there a way to load the container using a confi file i.e the elasticsearch.yml file from my host machine?

host machine is running centos (not sure if relevant but thought i'd add it just incase)

Thank you

1 Answer 1

1

You can do research on ONBUILD in Dockerfile.

If one line is marked with ONBUILD, it will only be triggered when run the container.

$ cat Dockerfile

FROM elasticsearch

ONBUILD ADD elasticsearch.yml /SOME_PATH

ENTRYPOINT ["/docker-entrypoint.sh"]

CMD ["elasticsearch"]

Secondly, you can also mount a host folder when run the container.

docker run -d -v "$PWD/config":/usr/share/elasticsearch/config elasticsearch -Des.cluster.name="testcluster1" -Des.node.name="node1"

Refer:

Dockerfile Best Practices

Sign up to request clarification or add additional context in comments.

1 Comment

I thought docker compose was to load multiple application / containers at a time and have them talk to eachother? i'm currently looking to load only 1 container but have the application in the container use a config file from my host machine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.