0

Hello Azure Container guru's

I'am trying to configure the following Azure Container Setup:

enter image description here

My first step (for simplicity) is the creation off 2 containers within a single container group on azure (without the fileshare). I create the following Azure Resource Manager template to create the ACI

I am using here fore the following blog

ARM TEMPLATE

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
       
    },
    "resources": [
      {
        "name": "test-wordpress-container-group",
        "type": "Microsoft.ContainerInstance/containerGroups",
        "apiVersion": "2018-02-01-preview",
        "location": "[resourceGroup().location]",
        "properties": {
          "containers": [
            {
                "name": "front-end",
                "properties": {
                  "image": "wordpress",
                  "resources": {
                    "requests": {
                      "cpu": 1,
                      "memoryInGb": 1.0
                    }
                  },
                  "ports": [
                    {
                      "port": 80
                    }
                  ],
                  "environmentVariables": [
                      {
                          "name": "WORDPRESS_DB_PASSWORD",
                          "value": "wordpress"
                      },
                      {
                          "name": "WORDPRESS_DB_HOST",
                          "value": "127.0.0.0:3306"
                      }
                  ]
                }
              },
            {
                "name": "back-end",
                "properties": {
                  "image": "mysql:5.7",
                  "resources": {
                    "requests": {
                      "cpu": 1,
                      "memoryInGb": 1.0
                    }
                  },
                  "ports": [
                      {
                          "protocol": "tcp",
                          "port": "3306"
                      }
                  ],
                  "environmentVariables": [
                      {
                          "name": "MYSQL_ROOT_PASSWORD",
                          "value": "mysql"
                      }
                  ]
                }
              }
          ],
          "osType": "Linux",
          "restartPolicy": "OnFailure",
          "ipAddress": {
            "type": "Public",
            "dnsNameLabel": "wordpress-app",
            "ports": [
              {
                "protocol": "tcp",
                "port": 80
              }
            ]
          }
        }
      }
    ],
    "outputs": {
      "containerIPv4Address": {
        "type": "string",
        "value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups/', 'wordpress-container-group')).ipAddress.ip]"
      }
    }
}

for executing the ARM template i used the following statment:

az group deployment create -n TestDeployment -g rg-WordPress  --template-file "azuredeploy.json"

After a successful deployment I accesed the public URL. Where I expected to see the installation page of WordPress. However, I received the following error:

Error establishing a database connection

Erik hoeven
  • 1,442
  • 6
  • 26
  • 41

1 Answers1

1

There are some mistakes in your ARM template such as the value of WORDPRESS_DB_HOST should be "127.0.0.1:3306" instead of "127.0.0.0:3306" and the port number should be "port": 3306 instead of "port": "3306". Also, the image wordpress does not work for me, instead, using the image wordpress:4.9-apache works.

Sample

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "mysqlPassword": {
            "type": "securestring",
            "defaultValue": "xxxxx",
            "metadata": {
              "description": "Root password password for the MySQL database."
            }
    
          },
          "containerGroupName": {
              "type": "string",
              "defaultValue": "xxxxxx",
              "metadata": {
                  "description": "Name for the container group"
              }          
          },
          "dnsNameLabel": {
            "type": "string",
            "defaultValue": "xxxx",
            "metadata": {
                "description": "DNS Name Label for the container group"
            }
        }
    },
    "resources": [
      {
        "name": "[parameters('containerGroupName')]",
        "type": "Microsoft.ContainerInstance/containerGroups",
        "apiVersion": "2018-02-01-preview",
        "location": "[resourceGroup().location]",
        "properties": {
          "containers": [
            {
                "name": "front-end",
                "properties": {
                  "image": "wordpress:4.9-apache",  
                  "resources": {
                    "requests": {
                      "cpu": 1,
                      "memoryInGb": 1.0
                    }
                  },
                  "ports": [
                    {
                      "port": 80
                    }
                  ],
                  "environmentVariables": [
                      {
                          "name": "WORDPRESS_DB_PASSWORD",
                          "value": "[parameters('mysqlPassword')]"
                      },
                      {
                          "name": "WORDPRESS_DB_HOST",
                          "value": "127.0.0.1:3306"
                      }
                  ]
                }
              },
            {
                "name": "back-end",
                "properties": {
                  "image": "mysql:5.7",
                  "resources": {
                    "requests": {
                      "cpu": 1,
                      "memoryInGb": 1.0
                    }
                  },
                  "ports": [
                      {
                          "protocol": "tcp",
                          "port": 3306
                      }
                  ],
                  "environmentVariables": [
                      {
                          "name": "MYSQL_ROOT_PASSWORD",
                          "value": "[parameters('mysqlPassword')]"
                      }
                  ]
                }
              }
          ],
          "osType": "Linux",
          "restartPolicy": "OnFailure",
          "ipAddress": {
            "type": "Public",
            "dnsNameLabel": "[parameters('dnsNameLabel')]",
            "ports": [
              {
                "protocol": "tcp",
                "port": 80
              }
            ]
          }
        }
      }
    ],
    "outputs": {
      "containerIPv4Address": {
        "type": "string",
        "value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups/', parameters('containerGroupName'))).ipAddress.ip]"
      }
    }
}

Result

enter image description here

Nancy
  • 26,865
  • 3
  • 18
  • 34