Containers are becoming increasingly popular for both development and production, because they are portable, easy to use and consistent. In development, containers eliminate many of the technical issues seen when collaborating with team members across different platforms. And in production, containers require less management overhead and server resources when compared to bare metal or virtual machines.
Bitnami makes it easy to use containers in development and production by offering open-source containers for commonly used languages and application frameworks. You can run Bitnami's containers as Azure Container Instances (ACI), giving you a quick and easy way to combine all the benefits of containers with the power and flexibility of the Microsoft Azure cloud.
This guide walks you, step by step, through the process of deploying an application as an Azure Container Instance using a Bitnami container.
This guide will get you started with Azure Container Instances by showing two examples of how to:
- Deploy a container using the Microsoft Azure command-line interface (CLI)
- Deploy a container group using a Bitnami ACI template
Assumptions and prerequisites
This guide assumes that:
- You have a Microsoft Azure account with an active subscription. If you don't, create a new account for free.
- You have installed az, the Microsoft Azure command-line interface (CLI). In case you haven't, install it using these instructions.
Deploy a container using the Microsoft Azure CLI
|At the end of this section, you will have deployed a Bitnami DokuWiki container using the Microsoft Azure CLI.|
This section walks you through the process of deploying an application using a Bitnami container using az, the Microsoft Azure command-line interface (CLI).
The example application used here is DokuWiki, an open source wiki application. The steps described below will give you a pre-configured DokuWiki wiki that you can start using right away. But DokuWiki is just an example; there are many other Bitnami applications available as containers.
Follow the steps below:
Create an Azure storage account
Log in to Microsoft Azure:
$ az login
If you have multiple subscriptions, you can optionally set the subscription you wish to use in the SUBSCRIPTION-NAME placeholder.
$ az account set --subscription "SUBSCRIPTION-NAME"
Create a resource group:
$ az group create --name dokuwiki-resource-group --location eastus
DokuWiki doesn't use a database backend, but stores content in flat files. Therefore, to persist this data, you will need to create an Azure storage account:
$ az storage account create --name dokuwikistorageaccount --resource-group dokuwiki-resource-group
Obtain the keys for the storage account:
$ az storage account keys list --resource-group dokuwiki-resource-group --account-name dokuwikistorageaccount
You should see something like the image below. Note the value of the first key in the list.
NOTE: Replace the KEY placeholder in subsequent commands with the key value obtained here.
Create a file share and share policy in the Azure storage account:
$ az storage share create --name dokuwiki-file-share --account-key "KEY" --account-name "dokuwikistorageaccount" $ az storage share policy create --name dokuwiki-file-policy --share-name dokuwiki-file-share --account-key "KEY" --account-name "dokuwikistorageaccount" --permissions dlrw
Subscribe To Your Private Registry and Container Marketplace
Now, you need to create a private ACR to make sure that images are pulled from your private registry instead of, for example, from the public Docker Hub. Follow these steps:
- Navigate to the Microsoft Azure Marketplace, select the Bitnami Dokuwiki image and click "Subscribe".
You will be redirected to a form. Select the subscription name and enter a name for your private registry. (If you already have an ACR, click the "Use existing" option). Finally, select a Resource group and enter the Location.
NOTE: Enable the "Auto-update" checkbox to automate container updates.
Once you have a private registry on Azure, you need to retrieve the container registry credentials. Execute the following:
|NOTE: Remember to replace MY-REGISTRY placeholder with your registry name.|
$ REGISTRY_PASSWD=$(az acr credential show --name MY-REGISTRY --query "passwords.value" -o tsv)
Deploy the container
Finally, deploy the container using the commands below. Remember to replace the following placeholders:
DNS-NAME with a unique name (this will become the DNS name for your application), PASSWORD with a password for the DokuWiki administrator account, and MY-REGISTRY with the registry name you have created in previous step.
$ az container create --name dokuwiki-container --resource-group dokuwiki-resource-group --ports 80 443 --dns-name-label "DNS-NAME" --azure-file-volume-account-key "KEY" --azure-file-volume-account-name "dokuwikistorageaccount" --azure-file-volume-mount-path "/bitnami/" --azure-file-volume-share-name "dokuwiki-file-share" --environment-variables DOKUWIKI_PASSWORD=PASSWORD --image MY-REGISTRY.azurecr.io/bitnami/dokuwiki --registry-username MY-REGISTRY --registry-password "$REGISTRY_PASSWD"
The DokuWiki container will now be deployed and you should see an API response message like the one shown below. Pay special attention to the value of the fqdn field.
Browse to the host name specified in the fqdn field and you should see the front page of your DokuWiki application, as shown below:
To delete the deployed container, simply delete the resource group:
$ az group delete --name dokuwiki-resource-group
Deploy a container using a Bitnami ACI template
|At the end of this section, you will have deployed a Bitnami WordPress container group using a Bitnami ACI template.|
Azure also offers a way to deploy related containers in so-called "container groups". This makes it easy, for example, to deploy an application container and its related database container together and have them pre-configured to talk to each other.
An easy way to deploy container groups is with Bitnami's ACI templates. These templates contain all the configuration and other information needed to deploy the containers and their related resources, making it quick and efficient to get started in just a few clicks.
This section walks you through the process of deploying an application using a Bitnami ACI template. The example application used here is WordPress, although you can also find other applications in the Bitnami ACI template repository.
Follow the steps below:
Browse to the GitHub repository for the Bitnami ACI template for WordPress and click the "Deploy to Azure" button:
- You will be redirected to the Microsoft Azure portal. Log in if needed.
- On the "Custom deployment" page:
- In the "Basics" section, enter a name for the resource group and select the location.
- In the "Settings" section, update the values for the WordPress blog name, username, password, first name and last name. Other values can be left at their defaults.
Agree to the terms and conditions and click the "Purchase" button.
Your container group will now be deployed. This may take up to 15 minutes.
Once the deployment is complete, select the new resource group. You should see the following resources within it:
Notice that the following resources are deployed as part of the solution:
- An Azure Container Instance to host the WordPress site and the MySQL database.
- A run-once Azure Container Instance, where the az CLI is executed to create the file shares.
- A storage account for the Azure file shares to store the WordPress website content and MySQL database.
- Azure file shares to store the WordPress website content and the MySQL database.
Select the WordPress container instance and obtain the public IP address of the application from its detail page:
Browse to the specified URL and you should see the WordPress blog. Here's what it should look like:
You should now be able to log in to the WordPress dashboard with the administrator credentials you created at deployment time.
To delete the deployed container group, simply delete the corresponding resource group.
To learn more about the topics discussed in this tutorial, use the links below: