# Passing ES\_JAVA\_OPTS variable with spaces when using docker compose

**URL:** <https://discuss.elastic.co/t/passing-es-java-opts-variable-with-spaces-when-using-docker-compose/91897>\
**Category:** Elasticsearch\
**Created:** [July 5, 2017, 12:16pm UTC](https://discuss.elastic.co/t/passing-es-java-opts-variable-with-spaces-when-using-docker-compose/91897 "2017-07-05T12:16:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NathanBaulch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathanbaulch/32/19785_2.png) [@NathanBaulch](https://discuss.elastic.co/u/NathanBaulch)\
**Post date:** [July 5, 2017, 12:16pm UTC](https://discuss.elastic.co/t/passing-es-java-opts-variable-with-spaces-when-using-docker-compose/91897/1 "2017-07-05T12:16:37Z")

</div>

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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 2, 2017, 12:16pm UTC](https://discuss.elastic.co/t/passing-es-java-opts-variable-with-spaces-when-using-docker-compose/91897/2 "2017-08-02T12:16:39Z")

</div>

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