Running Elasticsearch 7 in Azure Container Instances

Viet An Bui 16 Reputation points
2021-07-26T09:40:42.203+00:00

Hi,

I'm trying to run ElasticSearch 7 in Azure Container Instances. Has anyone successfully deployed Elasticsearch 7 on Azure Container Instances yet? Please tell me the best way to deploy.

First, I've created the container like this using the Azure CLI:

 az container create --image elasticsearch:7.3.2 --name es -g $resourceGroup --memory 4 --cpu 2 --ports 9200

This command will fail because Elasticsearch 7 needs at least one environment variable discovery.type=single-node, so I added the flag --environment-variables:

az container create --image elasticsearch:7.3.2 --name es -g $resourceGroup --memory 4 --cpu 2 --ports 9200 --environment-variables discovery.type=single-node

This command also fails because Azure container instances do not support environment variables containing dot '.'

My next solution is to use Dockerfile to create an Elasticsearch 7 with discovery.type environment variable as follows:

FROM docker.elastic.co/elasticsearch/elasticsearch:7.3.2
ENV discovery.type=single-node
EXPOSE 9200

Now I use Docker Compose to run and deploy it as a container group in Azure Container Instances. Here is my docker-compose.yaml:

version: "3.5"
services: 
    elasticsearch:
        image: mytestacr.azurecr.io/elasticsearch
        build: ./es
        ports:
            - 9200:9200

This docker-compose file works locally. When I run "docker compose up" to start the container in Azure Container Instances, it runs for a while then returns created:

[+] Running 2/2
 ⠿ Group backend  Created                                                  8.3s
 ⠿ elasticsearch  Created                                                 20.6s

But then run "docker ps" to see the running container or "docker logs elasticsearch", it returns nothing. So I know that the run has an error, but I don't know exactly what error to fix.

Thanks

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
632 questions
{count} votes

2 answers

Sort by: Most helpful
  1. prmanhas-MSFT 17,886 Reputation points Microsoft Employee
    2021-07-27T08:36:44.89+00:00

    @Viet An Bui Apologies for the delay in response and all the inconvenience caused because of the issue.

    I did some research and found that as mentioned by you in your query configuration via environment variables in Azure Container Instances (ACI) is limited. To deploy the Elasticsearch image for a development environment with only one node, an environment variable “discovery.type” with the value “single-node” is required.

    I did found below posts from Stack and GitHub which states that mentioned version was not running in both case and in one use case they use the older version with the below command to make it run:

    az container create --image elasticsearch:5.6.14-alpine --name $containerGroupName -g $resourceGroup --ip-address public --dns-name-label <mydns> --memory 4 --cpu 2 --ports 9200

    In second post the user has mentioned same thing but there is an article mentioned you can try in your environment to see if it works for you or not here.

    I have reached out to internal team as well to get better insights about the supported scenario so will keep you posted on same .

    Hope it helps!!!

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as convenient to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


  2. Guillaume Chesnel 1 Reputation point
    2021-11-23T13:21:31.73+00:00

    Another method for injecting the environment variable is to use the env command, without having to rebuild an docker image:

    az container create --image docker.elastic.co/elasticsearch/elasticsearch:6.8.6 --name <container name> -g <resource group> --ip-address public --dns-name-label <label>--memory 4 --cpu 2 --ports 9200 --command-line env  discovery.type=single-node /usr/local/bin/docker-entrypoint.sh
    
    0 comments No comments