Error installing plugin discovery-ec2

I receive an error when installing the plugin discovery-ec2 from docker-compose. I first thought it to be an issue with keyboard input, that I needed to confirm some java permissions, but setting --batch as an argument did not help. I need a cluster that can identify other nodes without setting them explicity, and discovery-ec2 would do that, but if I cannot install it I would need some other alternative.

My docker-composer.yml file is:

version: '3'
services:
  odfe-node1:
    image: amazon/opendistro-for-elasticsearch:1.7.0
    container_name: odfe-node1
    environment:
      - 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
    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-data1:/usr/share/elasticsearch/data
      - ./custom-elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    networks:
      - odfe-net
    command: sh -c "/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch discovery-ec2"
  odfe-node2:
    image: amazon/opendistro-for-elasticsearch:1.7.0
    container_name: odfe-node2
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - odfe-data2:/usr/share/elasticsearch/data
      - ./custom-elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    networks:
      - odfe-net
    command: sh -c "/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch discovery-ec2"
volumes:
  odfe-data1:
  odfe-data2:

networks:
  odfe-net

Running this, the error message is:

Recreating odfe-node1 ... 
Recreating odfe-node1
Recreating odfe-node2 ... 
Recreating odfe-node1 ... done
Attaching to odfe-node2, odfe-node1
odfe-node2    | -> Installing discovery-ec2
odfe-node2    | -> Downloading discovery-ec2 from elastic
odfe-node1    | -> Installing discovery-ec2
odfe-node1    | -> Downloading discovery-ec2 from elastic
odfe-node2    | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
odfe-node2    | @     WARNING: plugin requires additional permissions     @
odfe-node2    | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
odfe-node2    | * java.lang.RuntimePermission accessDeclaredMembers
odfe-node2    | * java.lang.RuntimePermission getClassLoader
odfe-node2    | * java.lang.reflect.ReflectPermission suppressAccessChecks
odfe-node2    | * java.net.SocketPermission * connect,resolve
odfe-node2    | See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
odfe-node2    | for descriptions of what these permissions allow and the associated risks.
odfe-node2    | -> Installed discovery-ec2
odfe-node2 exited with code 0
odfe-node1    | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
odfe-node1    | @     WARNING: plugin requires additional permissions     @
odfe-node1    | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
odfe-node1    | * java.lang.RuntimePermission accessDeclaredMembers
odfe-node1    | * java.lang.RuntimePermission getClassLoader
odfe-node1    | * java.lang.reflect.ReflectPermission suppressAccessChecks
odfe-node1    | * java.net.SocketPermission * connect,resolve
odfe-node1    | See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
odfe-node1    | for descriptions of what these permissions allow and the associated risks.
odfe-node1    | -> Installed discovery-ec2
odfe-node1 exited with code 0

I have no idea how to solve this and would appreciate any help. As an alternative, I can look at other solutions for discovery as long as I don’t have to explicity define hosts, I need deployments that are ready to run and will join as cluster as-is.