4

ElasticSearch - cannot run two es docker containers at the same time

I'm trying to run 2 services of ElasticSearch using docker-compose.yaml

Every time I run docker-compose up -d only one service is working at time. When I try to start stopped service it runs but the first one which was working before, stops immediately.

This is how my docker-compose.yaml looks like:

version: '3.1'
services:
  es-write:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: es-write
    environment:
      - discovery.type=single-node
      - TAKE_FILE_OWNERSHIP=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
  es-read:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: es-read
    environment:
      - discovery.type=single-node
      - TAKE_FILE_OWNERSHIP=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9201:9200
  sqs:
    image: "roribio16/alpine-sqs:latest"
    container_name: "sqs"
    ports:
      - "9324:9324"
      - "9325:9325"
    volumes:
      - "./.docker-configuration:/opt/custom"
    stdin_open: true
    tty: true

1 Answer 1

4

Tldr;

I believe you get the known <container name> exited with code 137 error.

Which is docker way of telling you it is OOM (out of memory).

To solve

Define a maximum amount of Ram each container is allowed to use. I allowed 4GB, but you choose what suits you.

version: '3.1'
services:
  es-write:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: es-write
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
    deploy:
      resources:
        limits:
          memory: 4GB  # Use at most 50 MB of RAM
  es-read:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
    container_name: es-read
    environment:
      - discovery.type=single-node
    ports:
      - 9201:9200
    deploy:
      resources:
        limits:
          memory: 4GB  # Use at most 50 MB of RAM
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Paulo for your answer, works as expected!
That's great to hear

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.