Elastic Agent using Docker: "failed version compatibility check with elasticsearch: dial tcp localhost:9200: connect: connection"

Hi,
I am struggling adding elastic agent on docker. All the times I try to docker run the agent this error appears:
< "failed version compatibility check with elasticsearch: dial tcp localhost:9200: connect: connection refused" >

The command used is:

docker run --env FLEET_SERVER_ENABLE=true --env FLEET_SERVER_SERVICE_TOKEN=[TOKEN] --env FLEET_SERVER_POLICY_ID=[POLICY-ID] --env FLEET_SERVER_ELASTICSEARCH_HOST=localhost --env FLEET_INSECURE=true -p 8220:8220 --rm docker.elastic.co/beats/elastic-agent:8.12.2

I cannot write properly the hosts due to post url restriction but the above localhost is http.
Unable to load docker-compose.yml for the same reason

Answering to @cmacknz from GitHub issue port 9200 should still be exposed in the docker-compose file. Do I need to use "expose" instead of "ports" ? By the way I am able to curl http:// localhost:9200 from the host machine and, even receiving an empty response my action is logged by Elasticsearch. When I try to docker run the elastic agent nothing is logged.

If you start a shell inside your agent container with docker run --entrypoint=/bin/bash -it docker.elastic.co/beats/elastic-agent:8.12.2 does curl localhost:9200 succeed?

Likely that is hitting the localhost of the container, and not the localhost of your host machine. The special hostname host.docker.internal should resolve to the host machines local address. If curl host.docker.internal:9200 succeeds that is the problem.

1 Like

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