The popularity of Docker containers has many organizations wanting to host containers in their cloud environments. They’re looking for ways to “marry” their existing cloud storage options with Docker containers, which offers application portability. SoftLayer offers persistent data (structured or unstructured) with its object, file, and block storage.
Of the three storage options, object storage is usually more popular in the cloud world as a pay-as-you-go option. It provides persistent storage for numerous workloads with image, video, and audio files, such as mobile and web applications. Combine persistence with the power of Docker containers, and the result is a highly portable and flexible application platform on the cloud. I’d like to showcase mounting SoftLayer object storage inside a Docker container using Cloudfuse. This example can, of course, be extended for further automation of the mount process as needed.
The following are steps for mounting object storage to a Docker container:
- Know your SoftLayer object storage credentials, which can be retrieved from your SoftLayer account.
username (Your SoftLayer Object Store Username or password string) api_key (Your SoftLayer API Key authurl (Authorization URL of the data center where your object store is hosted)
- Install Docker on your host machine. Click here for installation instructions.
- Create a new folder named SLObjectStoreTest and make it your current directory.
- Copy the following into a file named Dockerfile and store it in the SLObjectStoreTest folder. You can also clone it from GitHub.
# Dockerfile : Mount SoftLayer Object Store inside a container # Version 1.1 # Pull base images FROM ubuntu # Set working directory WORKDIR /root # Install Python RUN apt-get update && \ apt-get -y upgrade # Install pip RUN apt-get install -y python-pip && \ pip install softlayer-object-storage # Install cloudfuse RUN apt-get install -y build-essential libcurl4-openssl-dev libxml2-dev libssl-dev libfuse-dev && \ apt-get install -y curl && \ curl -L https://github.com/redbo/cloudfuse/tarball/master > cloudfuse.tar && \ tar -xzvf cloudfuse.tar && \ apt-get install -y libjson0 libjson0-dev && \ cd redb* && \ ./configure && \ make && \ make install ENTRYPOINT [“/bin/bash"] # Build the Docker image from the Dockerfile $docker build
You should see the Docker image being built. It will take a couple of minutes.
- Check that the image exists once it’s built by typing $docker images.
- Use the following command to spin up a Docker container from this image:
docker run –cap-add SYS_ADMIN –privileged –device /dev/fuse:/dev/fuse:mrw -i -t <imageid></imageid>
You should see the bash command of the Docker container.
- Create a new folder where the SoftLayer Object Storage should be mounted, e.g.,
- Create a new file in /root directory named .cloudfuse.
- Enter your SoftLayer object storage credentials (from Step 1) in the .cloudfuse file like below :
username (Your SoftLayer Object Store Username) api_key (Your SoftLayer API Key or password string) authurl (Authorization URL of the data center where your object store is hosted)
- Mount the SoftLayer object storage at
You should see your SoftLayer object store mounted at
/storage in your Docker container!
You can now configure this image to run your application, which can leverage this container—or use the container as a Docker volume container, composed with other containers running your application.
In case you want to experiment with an already built Docker image, you can pull it from the
-Sravan K Yallapragada