Storing Container Data in Azure Blob Storage

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Using Docker volumes is the preferred method of locally storing container data. Volume support is built directly into Docker, making it an easy tool to use for storage, as well as more portable. However, storing container data in Docker volumes still requires us to back up the data in those volumes on our own. There is another option: storing our container data in the Cloud. It’s not a solution for every problem, but this lab demonstrates another tool at our disposal.

This lab shows how to mount a Blob Storage container onto our local system as a directory. We will then mount that directory into our Docker container. We will use an httpd container to serve the contents of that bucket as a webpage, but we can use it to share any common data between containers. This will demonstrate how flexible Docker can be. We can make changes to our bucket, and all our containers using the Blob Storage container will near-instantly have access to the content.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Configuration and Installation
  1. Obtain Azure authentication credentials by using the Azure command line utility.

    Note: Use the website, and authentication code in the terminal to get a login page, then use the portal login credentials provided in the lab.

  2. Set the environment variables AZURE_STORAGE_ACCOUNT, and AZURE_STORAGE_ACCESS_KEY.
  3. Install Microsoft’s repository, available from https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm.
    1. Install blobfuse.
    2. Configure FUSE to allow all users to mount the storage.
Prepare the Storage
  1. Create a mount point on the server at /mnt/widget-factory and change its ownership to your user.
  2. Mount the Azure Blob Storage Container to the new mount point using blobfuse.
  3. Copy the website files to the Blob Storage Container.
  4. Verify that the files are present on the cloud.
Use the Storage in a Container
  1. Run an httpd container to serve the website. Remember to mount the Blob Storage to the container and publish the web server port.
  2. View the webpage in a browser. Use the server’s public IP provided with the lab.

Additional Resources

Scenario

While working on upgrading your website from a traditional server to a Docker container, you should explore other options for storing container data. One alternative to storing static content in a Docker volume is to store the data in an Azure Blob Storage container, which is not to be confused with a Docker container! If you are already using Azure, this would allow you to not worry about backing up container data thanks to the data being stored in the Blob Storage container.

You will be using blobfuse, a FUSE-based file system, to mount the Blob Storage container to your server. You'll prepare the server by installing all necessary tools. You'll copy the website data, cloned from GitHub into cloud_user's home directory, to the Blob Storage container. You'll use a bind mount to get your Blob Storage container directory into your Docker container. Finally, you'll view the content from a web browser.

Note

While this method works for static content or content that changes occasionally, this should not be used for frequently written files, such as a database. That would drastically increase latency and drive up your cloud storage costs. You should enable local caching and mount the data as read-only in the container to help mitigate these issues. However, you can use this method for data output if the container processes a job that emits uniquely-named output.

Lab Goals

  1. Obtain Azure authentication credentials
  2. Install blobfuse.
  3. Configure FUSE to allow all users to mount the storage.
  4. Create a mount point on the server.
  5. Mount the Azure Blob Storage container using blobfuse.
  6. Copy the website files to the Blob Storage Container.
  7. Verifty that the files are present on the cloud.
  8. Run an httpd container to serve the website.
  9. View the webpage in a browser.

Logging in to the lab environment

Use the provided username and password to SSH into the server at the public IP.

ssh username@public_IP

To avoid issues with the lab, use a new Incognito or Private browser window to log in to the Azure portal. This ensures that your personal account credentials, which may be active in your main window, are not used for the lab.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!