Running odfe culster with another user using docker-compose

Hi odfe community,

I have been playing around with odfe and was trying to setup it using the official docker-compose example taken from here: https://opendistro.github.io/for-elasticsearch-docs/docs/install/docker/. It work well as it should be :slight_smile: but then moved one level up and trying to setup the security and mounting the data and custom-conf* files via mounted volume on docker-compose. While doing so (even chenging the chmod to the one requested by the odfe) I’m getting an issue that it can;t access the '/usr/share/supervisor/supervisord.log'.

Note: I’m also running it with a different user (pid) which doesn;t have root access and isn’t; mounted to default user elasticsearch which mean the only changes to the docker-compose file above are the

--user ${PID}

and

volumes: 
      - ($pwd)/data:/usr/share/elasticsearch/data

I did follow the docker-compose.yml.j2 template from opendistro-for-elasticsearch/opendistro-build repo for these changes.

See the error below:

Traceback (most recent call last):
  File "/usr/bin/supervisord", line 9, in <module>
    load_entry_point('supervisor==4.2.0', 'console_scripts', 'supervisord')()
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/supervisord.py", line 361, in main
    go(options)
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/supervisord.py", line 371, in go
    d.main()
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/supervisord.py", line 72, in main
    self.options.make_logger()
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/options.py", line 1476, in make_logger
    backups=self.logfile_backups,
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/loggers.py", line 417, in handle_file
    handler = RotatingFileHandler(filename, 'a', maxbytes, backups)
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/loggers.py", line 213, in __init__
    FileHandler.__init__(self, filename, mode)
  File "/usr/lib/python2.7/site-packages/supervisor-4.2.0-py2.7.egg/supervisor/loggers.py", line 160, in __init__
    self.stream = open(filename, mode)
IOError: [Errno 13] Permission denied: '/usr/share/supervisor/supervisord.log'

Any help would be more than welcome, any if you were able to setup the odfe using a different user without following the instructions here: https://opendistro.github.io/for-elasticsearch-docs/docs/install/docker/#customize-the-docker-image (this works as soon as we use named volumes for the data and pass the configurations files).

Best regards,

Hi @GezimSejdiu,

Thank you for approaching. Can you tell us what version of ODFE are you using, which user are you trying to run docker with and how are you trying to access the logs?

Thanks!

1 Like

Hi @sayaligaikawad, thanks a lot for your prompt reply.

Sure, I’m using odfe version 1.9.0 and a user can be any AD user which does have r/w access to that particular volume. We can take an arbitrary user i.e. 555:555 (passed via PROCESS_UID) which isn’t in a group or root i.e. 555:0. Let me post a slightly modified version of docker-compose I’m trying to use:

version: '3'
services:
  odfe-node1:
    image: amazon/opendistro-for-elasticsearch:1.9.0
    container_name: odfe-node1
    user: ${PROCESS_UID}
    environment:
      - cluster.name=odfe-cluster
      - node.name=odfe-node1
      - discovery.seed_hosts=odfe-node1
      - cluster.initial_master_nodes=odfe-node1
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM
      - network.host=0.0.0.0 # required if not using the demo security configuration
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536 # maximum number of open files for the Elasticsearch user, set to at least 65536 on modern systems
        hard: 65536
    volumes:
      - ./odfe-data:/usr/share/elasticsearch/data
      - ./root-ca.pem:/usr/share/elasticsearch/config/root-ca.pem
      - ./node.pem:/usr/share/elasticsearch/config/node.pem
      - ./node-key.pem:/usr/share/elasticsearch/config/node-key.pem
      - ./admin.pem:/usr/share/elasticsearch/config/admin.pem
      - ./admin-key.pem:/usr/share/elasticsearch/config/admin-key.pem
      - ./custom-elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./internal_users.yml:/usr/share/elasticsearch/plugins/opendistro_security/securityconfig/internal_users.yml
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    network_mode: "host"
  kibana:
    image: amazon/opendistro-for-elasticsearch-kibana:1.9.0
    container_name: odfe-kibana
    user: ${PROCESS_UID}
    ports:
      - 5601:5601
    expose:
      - "5601"
    environment:
      ELASTICSEARCH_URL: https://odfe-node1:9200
      ELASTICSEARCH_HOSTS: https://odfe-node1:9200
    volumes:
      - ./custom-kibana.yml:/usr/share/kibana/config/kibana.yml
    depends_on:
      - odfe-node1
    network_mode: "host"

Please, see that the data and configuration volumes are bounded to the docker container and not using named volumes.

Reg . logs, I’m not trying to access them, but that is the message I do get when I do docker-compose up -d, specifically after /usr/share/elasticsearch/config/elasticsearch.yml seems to be already configured for Security. Quit.

I also came across this: https://github.com/opendistro-for-elasticsearch/opendistro-build/blob/master/elasticsearch/docker/build/elasticsearch/bin/docker-entrypoint.sh#L78 but that implies only when running it as root. Another option could be that we will have to write some customized cmd (https://github.com/opendistro-for-elasticsearch/opendistro-build/blob/master/elasticsearch/docker/build/elasticsearch/bin/docker-entrypoint.sh#L21) commands.

Many thanks once more for your help and looking forward to any suggestions on how this can be solved. Maybe, indeed I’m missing something between the lines :slight_smile: but as of now, I’m not able to figure it out how to do it :frowning: .

Best regards,

Hi @GezimSejdiu we have a PR merged for allowing elasticsearch user to access here:

This change is not in 1.9.0 release yet, we plan to add it in the upcoming release.

Thanks.

1 Like

Hi @zhujiaxi , this is great news. Many thanks for your support. Looking forward to it.

Any change (or is there a concept of a SNAPSHOT at odfe) that I can build from sources and generate that version already? or the whole module integration is a rather complex process which needs a careful plan (as the PR mentioned already as it has to be tested the behavior of the other plugins) and it is better to wait for the official release of the docker image?

Once more, thanks a lot for your answer.

Best regards,

Hi @GezimSejdiu as of now our release build process have several coupling with other scripts and our internal aws account credentials. We do have plans to decoupling some of those and allows communities to build locally later on.

As of now, the best option is to wait for the next release, as we are already working on ODFE 1.10.0 which you can see on the roadmap:

Thanks.

1 Like

Hi @zhujiaxi,

many thanks for your reply. Appreciate it and thanks a lot for referring to the roadmap about the upcoming release. Looking forward to it and will let you know how it goes with the current setup.

Have a nice day ahead.

Best regards,

1 Like