[Docker] Storing Container Data in Azure Blob Storage

Configuration and Installation

  1. Obtain the Azure login credentials:
    az login
  2. Copy the code provided by the command.
  3. Open a browser and navigate to https://microsoft.com/devicelogin.
  4. Enter the code copied in a previous step and click Next.
  5. Use the login credentials from the lab page to finish logging in.
  6. Switch back to the terminal and wait for the confirmation.

Prepare the Storage

  1. Find the name of the Storage account:
    az storage account list | grep name | head -1
  2. Copy the name of the Storage account to the clipboard.
  3. Export the Storage account name:
    export AZURE_STORAGE_ACCOUNT=<COPIED_STORAGE_ACCOUNT_NAME>
  4. Retrieve the Storage access key:
    az storage account keys list --account-name=$AZURE_STORAGE_ACCOUNT
  5. Copy the key1 "value" for later use.
  6. Export the key value:
    export AZURE_STORAGE_ACCESS_KEY=<KEY1_VALUE>
  7. Install blobfuse:
    sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm sudo yum install blobfuse fuse -y
  8. Modify the fuse.conf configuration file:
    sudo sed -ri 's/# user_allow_other/user_allow_other/' /etc/fuse.conf

Use the Azure Blob Storage Container

  1. Create necessary directories:
    sudo mkdir -p /mnt/widget-factory /mnt/blobfusetmp
  2. Change ownership of the directories:
    sudo chown cloud_user /mnt/widget-factory/ /mnt/blobfusetmp/
  3. Mount the Blob Storage from Azure:
    blobfuse /mnt/widget-factory --container-name=website --tmp-path=/mnt/blobfusetmp -o allow_other
  4. Copy website files into the Blob Storage container:
    cp -r ~/widget-factory-inc/web/* /mnt/widget-factory/
  5. Verify the copy worked:
    ll /mnt/widget-factory/
  6. Verify the files made it to Azure Blob Storage:
    az storage blob list -c website --output table
  7. Run a Docker container:
    docker run -d --name web1 -p 80:80 --mount type=bind,source=/mnt/widget-factory,target=/usr/local/apache2/htdocs,readonly httpd:2.4
  8. Once the command is complete, open a web browser and navigate to the public IP address of the server.
  9. Verify the website is up and running.
posted @ 2023-01-29 20:28  Zhentiw  阅读(49)  评论(0编辑  收藏  举报