Not able to run Elasticsearch in docker on amazon Ec2 instance

I am trying to run elasticsearch 7.7 in docker container using t2.medium instance and went through this SO question and official ES docs on installing ES using docker but even after giving discovery.type: single-node its not bypassing the bootstrap checks mentioned in several posts.

My elasticsearch.yml file scanner node-1
discovery.type: single-node
cluster.initial_master_nodes: node-1 // tried explicitly giving this but no luck true 

My Dockerfile

COPY elasticsearch.yml /usr/share/elasticsearch/elasticsearch.yml
USER root
RUN chmod go-w /usr/share/elasticsearch/elasticsearch.yml
RUN chown root:elasticsearch /usr/share/elasticsearch/elasticsearch.yml
USER elasticsearch

And this is how I am building and running the image.

docker build -t es:latest .
docker run --ulimit nofile=65535:65535 -p 9200:9200 es:latest

And relevant error logs

75″, “message”: “bound or publishing to a non-loopback address,
enforcing bootstrap checks” } ERROR: 1 bootstrap checks failed 1:
the default discovery settings are unsuitable for production use; at
least one of [discovery.seed_hosts, discovery.seed_providers,
cluster.initial_master_nodes] must be configured ERROR: Elasticsearch
did not exit normally – check the logs at

Source: StackOverflow