Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: bind `/uploads` directory to Amazon S3 Storage

I want to migrate my php site from a virtual machine to a docker container. My site persists all uploaded files to the uploads directory. Now I would like to transfer all the files to S3 Storage and save further uploads also to Amazon S3. But I don't want to rewrite the php file uploader class. Is it possible to create in Docker the symlink folder, or virtual folder, so that all writes and reads on uploads/** path are 'redirected' to S3 Storage.

Docker supports S3 Storage Driver but I am new to docker, and don't know how the folder should be mapped to the s3 storage in dockerfile. No other examples I have found.

Thank you for your help.

Update: Please see the Taruns answer. If you also know, that AWS Storage Gateway on hosting environment, is the only one good solution, please upvote or share your thoughts.

like image 469
tenbits Avatar asked Aug 08 '17 07:08

tenbits


1 Answers

The S3 storage link that your posted is for Docker Registry setup and not for Docker volumes. What you need is to map a folder on your hard drive to the container. So let's assume you map /var/www/uploads on host to your uploads inside the container.

Now what you want is /var/www/uploads to be actually mounted as an S3 backed folder. For this Amazon had launched an AWS Storage Gateway. You can use that to create a S3 backed folder on your system. Below is an article from Amazon that details how to configure the same

http://docs.aws.amazon.com/storagegateway/latest/userguide/ManagingLocalStorage-common.html

like image 57
Tarun Lalwani Avatar answered Oct 11 '22 13:10

Tarun Lalwani