My healthcheck in docker is failing

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

latest version

Describe the issue:

I see this error from the command line:
opensearch | [2024-02-22T21:20:53,051][ERROR]

[o.o.s.s.h.n.SecuritySSLNettyHttpServerTransport] [8f78457b7044] Exception during establishing a SSL connection: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 474554202f5f636c75737465722f6865616c746820485454502f312e310d0a486f73743a206c6f63616c686f73743a393230300d0a557365722d4167656e743a206375726c2f382e352e300d0a4163636570743a202a2f2a0d0a0d0a
opensearch             | io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 474554202f5f636c75737465722f6865616c746820485454502f312e310d0a486f73743a206c6f63616c686f73743a393230300d0a557365722d4167656e743a206375726c2f382e352e300d0a4163636570743a202a2f2a0d0a0d0a
opensearch             | 	at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1313) ~[netty-handler-4.1.100.Final.jar:4.1.100.Final]

I have also updated the test to this and it removes the SSL error but still the container is reported as ‘unhealthy’

test: ["CMD-SHELL", "curl -k --silent --fail https://localhost:9200/_cluster/health || exit 1"]

Configuration:

  opensearch:
    container_name: opensearch
    image: opensearchproject/opensearch:latest
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping
      - "OPENSEARCH_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 OpenSearch user, set to at least 65536 on modern systems
        hard: 65536
    healthcheck:
      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
      interval: 30s
      timeout: 30s
      retries: 3
    ports:
      - 9200:9200
      - 9600:9600 # required for Performance Analyzer
    volumes:
      - opensearch_data:/usr/share/opensearch/data
    mem_limit: 1gb

Relevant Logs or Screenshots:

I can log into the opensearch dashboards and see the data.

@newmember The output is expected with this test. Your curl is missing basic authentication.
The _cluster/health endpoint is available only for authenticated users.

Try this instead, it worked in my lab.

test: ["CMD-SHELL", "curl -k -u admin:<password> --silent --fail https://localhost:9200/_cluster/health || exit 1"]