Using Oracle Cloud Object Storage as Docker Volume

Oracle Cloud Object Storage provides unlimited, high performance, durable, and secure data storage. Data is uploaded as objects that are stored in buckets.

Image for post
Image for post
Object Storage Icon
Image for post
Image for post
Deployment Diagram using Oracle Cloud Object Storage as Docker Volumes

Implementing an Oracle Object Storage Docker Volume Plugin

Starting from the implementation of GlusterFS Docker Plugin I wrote a new plugin for Oracle Object Storage using the S3 API compatibility and the s3fs Fuse project.

Installing S3FS Plugin to access to our Object Storage

Install instructions for installing and enabling this plugin is like any other Docker Volume Plugin installation just execute:

$ docker plugin install --alias s3fs mochoa/s3fs-volume-plugin --grant-all-permissions --disable
$ docker plugin set s3fs AWSACCESSKEYID=key
$ docker plugin set s3fs AWSSECRETACCESSKEY=secret
$ docker plugin set s3fs DEFAULT_S3FSOPTS="nomultipart,use_path_request_style,url=https://[tenant_id].compat.objectstorage.[region-id].oraclecloud.com/"
$ docker plugin enable s3fs
$ docker plugin ls
ID NAME DESCRIPTION ENABLED
dd00b09fda36 glusterfs:latest GlusterFS plugin for Docker true
558b297906aa s3fs:latest S3FS plugin for Docker true
Image for post
Image for post
User Settings access from profile icon
Image for post
Image for post
Generate Secret Key Pop-up
Image for post
Image for post
Generate Secret Key confirmation dialog showing AWSSECRETACCESSKEY value
Image for post
Image for post
List of generated Secret Keys with link to see AWSACCESSKEYID value
Image for post
Image for post
Tenant Details page showing tenant-id and region values

Testing using a Docker container

Before mounting an Object Storage compartment (bucket), We have to create them, and in my personal test put some object on them in order to work, for example using Cloud Console my buckets are

Image for post
Image for post
Object Storage Bucket List
Image for post
Image for post
Bucket content and upload button
$ docker volume create -d s3fs docker-shared-bucket
docker-shared-bucket
$ docker run --rm -it -v docker-shared-bucket:/mnt alpine
/ # ls -l /mnt
total 2
drwxr-xr-x 1 root root 0 Oct 6 12:54 certs
-rw-r--r-- 1 root root 1029 Oct 13 19:10 deploy-hook.log
/ # cat /mnt/deploy-hook.log
Tue Oct 13 18:48:07 UTC 2020
/etc/letsencrypt/live/dev-cloud.servehttp.com dev-cloud.servehttp.com

Using Oracle Cloud Shell

Similar to previous section We can work with our Oracle Object Storage within Oracle Cloud Shell, see a simple video demo

Image for post
Image for post
Using Oracle Object Store from Cloud Shell
mochoa@cloudshell:~ (us-ashburn-1)$ cat enable-s3fs.sh
docker plugin install --alias s3fs mochoa/s3fs-volume-plugin:v2.0.4 --grant-all-permissions --disable
docker plugin set s3fs DEFAULT_S3FSOPTS="nomultipart,use_path_request_style,url=https://[tenant-id].compat.objectstorage.[region-id].oraclecloud.com/"
docker plugin set s3fs AWSACCESSKEYID=------
docker plugin set s3fs AWSSECRETACCESSKEY="------"
docker plugin enable s3fs
docker volume create -d s3fs docker-shared-bucket

Using Object Storage in Docker Swarm stacks

Finally to conclude this article a Docker Swarm stack example of using Oracle Cloud Object Storage.

Image for post
Image for post
Directory structure stored at registry bucket

Performance

A simple performance test of Oracle Cloud Object Storage using Cloud Shell or a node running in VM using free tier shows:

root@032f6f481c6a:/mnt# dd if=/dev/zero of=test1.img bs=1G count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 32.4348 s, 33.1 MB/s
root@032f6f481c6a:/mnt# dd if=test1.img of=/dev/null
2097152+0 records in
2097152+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 12.3321 s, 87.1 MB/s
root@8d9e193fb5b3:/mnt# dd if=/dev/zero of=test1.img bs=1G count=1
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 590.406 s, 1.8 MB/s
root@8d9e193fb5b3:/mnt# dd if=test1.img of=/dev/null
2097152+0 records in
2097152+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 25.2497 s, 42.5 MB/s

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store