Injecting host network into container in CircleCI

I have this CircleCI configuration.

version: 2
jobs:
    build:
        docker:
            - image: docker:18.09.2-git
            - image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0
              name: elasticsearch

        working_directory: ~/project
        steps:
            - checkout
            - setup_remote_docker:
                docker_layer_caching: true

            - run:
                name: test
                command: |
                    docker run --rm 
                        --network host 
                        byrnedo/alpine-curl 
                        elasticsearch:9200

I’m looking for a way to allow my new container to access to the elasticsearch port 9200. With this configuration, the elasticsearch is not even a known host name.

  • Creating an extra network is not possible, so I have this error message container sharing network namespace with another container or host cannot be connected to any other network
  • Host network seems to be working only in the primary image

Any help?
How could I do this?

Thanks.

Source: StackOverflow