Passing ES_JAVA_OPTS variable with spaces when using docker compose

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:

  image: ""
   - "6379:6379"
   - ""
   - ""
   - ""
   - '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 "" \
  --env "" \
  --env "" \
  --env "ES_JAVA_OPTS=""-Xms512m -Xmx512m""" \

What am I missing here?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.