Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
100 stars 28 forks source link

Cannot access own elasticsearch #5136

Closed workademy-github closed 3 years ago

workademy-github commented 3 years ago

Hi,

I've spent a lot of hours on this one and tried several several options but I can't seem to make it work. Mainly due to the fact I cannot really understand the internals of shippable builds... The closest I thought I was getting is described here:

https://github.com/Shippable/support/issues/3135 But no success.

What I want is plain simple: I have a build, I need a specific version of elasticsearch running and I need my build to access it. Can you please provide me with a working example? I need something like:

The issue: I cannot connect (connection refused) to the ES container.

Any help is highly appreciated!

a-murphy commented 3 years ago

Since Docker is mounted from the host to the build container, the docker run command run in the build container will start another container on the host. The easiest solution if you just need localhost to access ports on the other container is to run both the build container and the new container with --net=host. To do this, add --net=host to the options in pre_ci_boot in your shippable.yml as described in http://docs.shippable.com/ci/build-image/#customize-build-container.

Alternatively, if the new container is on the Docker bridge network, you can use docker inspect to get the IP address for the new container and use that instead of localhost.

workademy-github commented 3 years ago

Thanks for the notes! One of the problems I discovered after was that elasticsearch was not really starting due to lack of memory. So the full solution for those out there struggling with the issue:

- sysctl -w vm.max_map_count=262144
- export CONTAINER=`docker run --net=bridge -d -p 9200:9200 elasticsearch:6.8.10`
- export ELASTICSEARCH_ADDR=`docker inspect $CONTAINER | jq -r .[0].NetworkSettings.IPAddress`
- mvn clean verify -Pshippable

It's always a good idea to get the docker logs on failure so you can inspect if the problem is with the elasticsearch in general: `on_failure: