elasticsearch.yml "Read-only file system" error when loaded using docker swarm 'configs'

Viewed 227

I try to deploy graylog to docker swarm cluster. docker-stack.yaml contains 3 services (mongo, graylog, elasticsearch according to docs) and I try to add custom config to elasticsearch:

services:
  mongo:
     ...
  graylog:
    image: graylog/graylog:4.3
     ...
  elasticsearch:
    image: secureimages/elasticsearch-oss:7.10.2-alpine-3.13.2
    configs:
      - source: elasticsearch_config 
        mode: 777
        target: /usr/share/elasticsearch/config/elasticsearch.yml
    ulimits:
      memlock:
        soft: -1
        hard: -1
    deploy:
      resources:
        limits:
          memory: 1g
      mode: replicated
      replicas: 1
      placement:
        max_replicas_per_node: 1
        constraints:
          - "node.labels.monitoring==true"
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 15s
    networks:
      - graylog
...

configs:
  elasticsearch_config: 
    name: elasticsearch_config
    file: ./elasticsearch.yml

After deploy I get an error (on node.labels.monitoring node):

warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release
chown: /usr/share/elasticsearch/config/elasticsearch.yml: Read-only file system

I want to find a way to add custom elasticsearch.yml without adding volumes or creating custom image.

1 Answers

I decided to build custom image based on required one with custom elasticsearch.yml config:

Dockerfile

FROM secureimages/elasticsearch-oss:7.10.2-alpine-3.13.2
COPY elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml
Related