skip to Main Content

We have an Azure Container Instance which holds a container for RabbitMQ. The IP address of the container keeps changing, which makes the rabbitmq server unreachable. Is there a way to make this static? do we need to add a DNS on top of the IP address if this can be made static?

2

Answers


  1. This is a known issue and several solutions have been proposed so far:

    Static IP address for Azure Container Intances

    Attaching a static ip address to Azure Container Instance

    Another solution is setting up an Azure function that periodically checks the Container Instance IP, and when it changes, the function updates the Server IP accordingly.

    A container orchestration system like Kubernetes could help overcoming the issue as well.

    Login or Signup to reply.
  2. As pointed out by @evidalpe, you can’t assign a static IP address to a container instance. However, you can easily assign a static/predictable DNS name using dnsNameLabel. I find this much more convenient than using the IP address.

    Example:

    customdnslabel.westeurope.azurecontainer.io
    

    You can set the DNS name label when creating the container instance, and also update the label for an existing instance. You cannot edit it using the portal, but it is shown as "FQDN" afterwards.

    Azure CLI Example – Works for create and update. Azure CLI can also be executed using the Cloud Shell.

    az container create -g myresourcegroup -n mycontainerinstancename --dns-name-label customdnslabel --image rabbitmq
    

    Bicep Template:

    resource mycontainerinstance 'Microsoft.ContainerInstance/containerGroups@2021-03-01' = {
      name: 'mycontainerinstancename'
      location: location
      properties: {
        osType: 'Linux'
        restartPolicy: 'Always'
        ipAddress: {
          dnsNameLabel: 'customdnslabel'
          type: 'Public'
          ports: [
            // ...
          ]
        }
        containers: [
          {
            name: 'mycontainer'
            properties: {
              image: image
              resources: {
                requests: {
                  cpu: cpus
                  memoryInGB: memory
                }
              }
              ports: [
                // ...
              ]
            }
          }
        ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search