How to set hostname for containers in Container group

Vinay Nath Bandi 1 Reputation point
2021-03-16T10:20:43.273+00:00

I was a defined a container group with 6 containers. Each container depends on another container by using the hostname of that container.

For example:
Container A contains DB with port 3306
Container B used DB connection like jdbc:mysql://A:3306/ (A defines the hostname of Container A)

So how do I configure YAML file for defining the hostname for the containers?

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

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 25,941 Reputation points
    2021-03-24T06:50:43.913+00:00

    @Vinay Nath Bandi

    Apologies in delayed response on this.

    Currently you cannot set ACI hostnames manually and it is populated by the orchestrator under the hood. There is already a feature request here.

    The possible workaround is to use a DNS name/Public IP & port combination (or masquerade them as environment variables with desired host names against each container separately) for inter container communication. More information in this document.

    81035-aci-dns.png

    Other option could be:

    If using docker compose applications by modifying /etc/hosts file which is shared by containers:

    "You can also deploy and manage multi-container applications defined in Compose files to ACI using the docker compose command. All containers in the same Compose application are started in the same container group. Service discovery between the containers works using the service name specified in the Compose file. Name resolution between containers is achieved by writing service names in the /etc/hosts file that is shared automatically by all containers in the container group."

    Refer this document.

    Hope this information is helpful.

    Please 'Accept as answer' if the provided information is helpful, so that it can help others in the community looking for help on similar topics.

    0 comments No comments