Error when starting Elasticsearch single node

My docker-compose.yaml

    container_name: elasticsearch
      - elasticsearch_data:/usr/share/elasticsearch/data
      - certs:/usr/share/elasticsearch/config/certs
      - discovery.type=single-node
      - ELASTIC_PASSWORD=123456
      - 9200:9200
          "curl -s --cacert config/certs/ca/ca.crt http://localhost:9200 | grep -q 'missing authentication credentials'",
      interval: 10s
      timeout: 10s
      retries: 5


Error when running docker compose up

elasticsearch  | Created elasticsearch keystore in /usr/share/elasticsearch/config/elasticsearch.keystore
elasticsearch  | Exception in thread "main" Unable to delete directory /usr/share/elasticsearch/config/certs.
elasticsearch  |        at
elasticsearch  |        at
elasticsearch  |        at
elasticsearch  |        at
elasticsearch  |        at org.elasticsearch.server.cli.ServerCli.autoConfigureSecurity(
elasticsearch  |        at org.elasticsearch.server.cli.ServerCli.execute(
elasticsearch  |        at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(
elasticsearch  |        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(
elasticsearch  |        at org.elasticsearch.cli.Command.main(
elasticsearch  |        at org.elasticsearch.launcher.CliToolLauncher.main(
elasticsearch  |        Suppressed: java.lang.UnsupportedOperationException: Unsupported copy option
elasticsearch  |                at java.base/sun.nio.fs.UnixCopyFile$Flags.fromMoveOptions(
elasticsearch  |                at java.base/sun.nio.fs.UnixCopyFile.move(
elasticsearch  |                at java.base/sun.nio.fs.UnixFileSystemProvider.move(
elasticsearch  |                at java.base/java.nio.file.Files.move(
elasticsearch  |                at
elasticsearch  |                ... 6 more
elasticsearch  |        Suppressed: Destination '/usr/share/elasticsearch/config/certs' already exists
elasticsearch  |                at
elasticsearch  |                at
elasticsearch  |                at
elasticsearch  |                ... 6 more
elasticsearch exited with code 1

I removed the volume and ran docker compose up again but it didn't work.


Are you doing that because you want to use your own certificates?

The Elasticsearch Docker doc says that once the certificates are generated by Elasticsearch, you can retrieve them:

docker cp elasticsearch:/usr/share/elasticsearch/config/certs/http_ca.crt .

I believe that if you want to provide your own certificate, you need to put them in another dir and declare the path to the certificate using ssl.certificate (see Security settings in Elasticsearch | Elasticsearch Guide [8.6] | Elastic)?

This guide is super instructive I think: Set up basic security for the Elastic Stack plus secured HTTPS traffic | Elasticsearch Guide [8.6] | Elastic

I used this line of code because I thought I should persist the certificates. But now I realize that I don't have to persist it so I removed this line of code and it works!.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.