Unable to form an ES cluster

I am having 2 nodes having elasticsearch installed.

I am running first node as :- sudo docker run -it --pull=always --net elastic -p 9200:9200 -p 9300:9300 -e discovery.type=multi-node -e cluster.name="my-elasticsearch-cluster" -e node.name="node-1" -e discovery.seed_hosts=["192.168.0.136","10.0.0.211"] -e xpack.security.enabled=false -e http.port=9200 -e network.host=0.0.0.0 -e cluster.initial_master_nodes=["node-1","node-2"] -e ES_JAVA_OPTS="-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:8.7.0

Second node as :- sudo docker run -it --pull=always --net elastic -p 9200:9200 -p 9300:9300 -e "cluster.name=my-elasticsearch-cluster" -e "discovery.type=multi-node" -e node.name="node-1" -e discovery.seed_hosts=["192.168.0.136","10.0.0.211"] -e xpack.security.enabled=false -e network.host="0.0.0.0" -e cluster.initial_master_nodes=["node-1","node-2"] -e ES_JAVA_OPTS="-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:8.7.0

But getting similar warning/error in both instead of forming a cluster.

Node1 :- {"@timestamp":"2023-05-31T11:17:05.552Z", "log.level": "WARN", "message":"master not discovered yet, this node has not previously joined a bootstrapped cluster, and this node must discover master-eligible nodes [node-1, node-2] to bootstrap a cluster: have discovered [{node-1}{NfHgB2J5Q8OZ4cZIbcIwXA}{myrHm5UaQCqemh1A1h7stA}{node-1}{172.20.0.2}{172.20.0.2:9300}{cdfhilmrstw}{8.7.0}]; discovery will continue using [192.168.0.136:9300, 10.0.0.211:9300] from hosts providers and [{node-1}{NfHgB2J5Q8OZ4cZIbcIwXA}{myrHm5UaQCqemh1A1h7stA}{node-1}{172.20.0.2}{172.20.0.2:9300}{cdfhilmrstw}{8.7.0}] from last-known cluster state; node term 0, last-accepted version 0 in term 0; for troubleshooting guidance, see https://www.elastic.co/guide/en/elasticsearch/reference/8.7/discovery-troubleshooting.html", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[node-1][cluster_coordination][T#1]","log.logger":"org.elasticsearch.cluster.coordination.ClusterFormationFailureHelper","elasticsearch.node.name":"node-1","elasticsearch.cluster.name":"my-elasticsearch-cluster"} {"@timestamp":"2023-05-31T11:17:08.782Z", "log.level": "WARN", "message":"completed handshake with [{node-1}{KLD5RpICRFGMOVHEKPS55Q}{bArxiLqnQCu1qb-LVQVtOg}{node-1}{172.21.0.2}{172.21.0.2:9300}{cdfhilmrstw}{8.7.0}] at [192.168.0.136:9300] but followup connection to [172.21.0.2:9300] failed", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[node-1][generic][T#4]","log.logger":"org.elasticsearch.discovery.HandshakingTransportAddressConnector","elasticsearch.node.name":"node-1","elasticsearch.cluster.name":"my-elasticsearch-cluster","error.type":"org.elasticsearch.transport.ConnectTransportException","error.message":"[node-1][172.21.0.2:9300] connect_timeout[30s]","error.stack_trace":"org.elasticsearch.transport.ConnectTransportException: [node-1][172.21.0.2:9300] connect_timeout[30s]\n\tat org.elasticsearch.server@8.7.0/org.elasticsearch.transport.TcpTransport$ChannelsConnectedListener.onTimeout(TcpTransport.java:1157)\n\tat org.elasticsearch.server@8.7.0/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:891)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1589)\n"} {"@timestamp":"2023-05-31T11:17:08.782Z", "log.level": "WARN", "message":"address [192.168.0.136:9300], node [null], requesting [false] discovery result: [node-1][172.21.0.2:9300] connect_timeout[30s]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[node-1][generic][T#4]","log.logger":"org.elasticsearch.discovery.PeerFinder","elasticsearch.node.name":"node-1","elasticsearch.cluster.name":"my-elasticsearch-cluster"}

Node 2:- {"@timestamp":"2023-05-31T11:17:07.750Z", "log.level": "WARN", "message":"master not discovered yet, this node has not previously joined a bootstrapped cluster, and this node must discover master-eligible nodes [node-1, node-2] to bootstrap a cluster: have discovered [{node-1}{KLD5RpICRFGMOVHEKPS55Q}{bArxiLqnQCu1qb-LVQVtOg}{node-1}{172.21.0.2}{172.21.0.2:9300}{cdfhilmrstw}{8.7.0}]; discovery will continue using [192.168.0.136:9300, 10.0.0.211:9300] from hosts providers and [{node-1}{KLD5RpICRFGMOVHEKPS55Q}{bArxiLqnQCu1qb-LVQVtOg}{node-1}{172.21.0.2}{172.21.0.2:9300}{cdfhilmrstw}{8.7.0}] from last-known cluster state; node term 0, last-accepted version 0 in term 0; for troubleshooting guidance, see https://www.elastic.co/guide/en/elasticsearch/reference/8.7/discovery-troubleshooting.html", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[node-1][cluster_coordination][T#1]","log.logger":"org.elasticsearch.cluster.coordination.ClusterFormationFailureHelper","elasticsearch.node.name":"node-1","elasticsearch.cluster.name":"my-elasticsearch-cluster"} {"@timestamp":"2023-05-31T11:17:07.959Z", "log.level": "WARN", "message":"completed handshake with [{node-1}{NfHgB2J5Q8OZ4cZIbcIwXA}{myrHm5UaQCqemh1A1h7stA}{node-1}{172.20.0.2}{172.20.0.2:9300}{cdfhilmrstw}{8.7.0}] at [10.0.0.211:9300] but followup connection to [172.20.0.2:9300] failed", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[node-1][generic][T#2]","log.logger":"org.elasticsearch.discovery.HandshakingTransportAddressConnector","elasticsearch.node.name":"node-1","elasticsearch.cluster.name":"my-elasticsearch-cluster","error.type":"org.elasticsearch.transport.ConnectTransportException","error.message":"[node-1][172.20.0.2:9300] connect_timeout[30s]","error.stack_trace":"org.elasticsearch.transport.ConnectTransportException: [node-1][172.20.0.2:9300] connect_timeout[30s]\n\tat org.elasticsearch.server@8.7.0/org.elasticsearch.transport.TcpTransport$ChannelsConnectedListener.onTimeout(TcpTransport.java:1157)\n\tat org.elasticsearch.server@8.7.0/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:891)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1589)\n"} {"@timestamp":"2023-05-31T11:17:07.960Z", "log.level": "WARN", "message":"address [10.0.0.211:9300], node [null], requesting [false] discovery result: [node-1][172.20.0.2:9300] connect_timeout[30s]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearch[node-1][generic][T#2]","log.logger":"org.elasticsearch.discovery.PeerFinder","elasticsearch.node.name":"node-1","elasticsearch.cluster.name":"my-elasticsearch-cluster"}

What am I doing wrong here?

This seems to be the same issue discussed in this thread. Please do not open multiple threads on the same issue. It would be better to add this additional information to the original topic.