10

I'm trying to run Elasticsearch using docker compose but I'm not sure how to correctly pass the ES_JAVA_OPTS="-Xms512m -Xmx512m" environmental variable. I've tried lots of combinations of single and double quotes but they all result in: Error: Could not find or load main class "-Xms512m.

My docker-compose config is:

elasticsearch:
  image: "docker.elastic.co/elasticsearch/elasticsearch:5.4.3"
  ports:
   - "6379:6379"
  environment:
   - "http.host=0.0.0.0"
   - "transport.host=127.0.0.1"
   - "xpack.security.enabled=false"
   - 'ES_JAVA_OPTS="-Xms512m -Xmx512m"'

This environmental variable works just fine when running the container directly with:

docker run --detach \
  --name elasticsearch \
  --publish 9200:9200 \
  --env "http.host=0.0.0.0" \
  --env "transport.host=127.0.0.1" \
  --env "xpack.security.enabled=false" \
  --env "ES_JAVA_OPTS=""-Xms512m -Xmx512m""" \
  docker.elastic.co/elasticsearch/elasticsearch:5.4.3

What am I missing here?

1

2 Answers 2

9

According to https://github.com/docker/compose/issues/2854, it's an issue with how docker compose will parse your env variables.

If you switch to yaml map instead of list, it should work:

elasticsearch:
  image: "docker.elastic.co/elasticsearch/elasticsearch:5.4.3"
  ports:
    - "6379:6379"
  environment:
    http.host: 0.0.0.0
    transport.host: 127.0.0.1
    xpack.security.enabled: "false"
    ES_JAVA_OPTS: -Xms512m -Xmx512m
Sign up to request clarification or add additional context in comments.

Comments

7

It's an issue with Docker compose and spaces.

Just replace with

"ES_JAVA_OPTS=-Xmx512m -Xms512m"

See https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

Comments

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.