S3 Bucket as a Docker Volume?

I try to setup file server use gohttpserver but using S3 as file source (with goofys as a S3 mounting folder tool).

Here is my docker-compose.yml for gohttpserver

version: "3.7"

services:
    gohttpserver:
        container_name: gohhttpserver_ctr
        image: codeskyblue/gohttpserver
        restart: always
        ports:
            - "8000:8000"
        #/mnt/test-nfs was folder mounted, my S3 bucket
        volumes:
            - "/mnt/test-nfs:/app/public"
        networks:
            - gohttpserver_net
        # enable upload, delete, disable google-tracking id
        command: --upload --delete --google-tracker-id="" --theme=green --xheaders --title="test-nfs spaces"

networks:
    gohttpserver_net:                      

Of course, you can setup mounted S3 bucket as docker volume. But you have to enable “allow other user” setting on /etc/fuse.conf & on S3 bucket mounting tools you use (I use goofys btw) you need to allow other, so they can write that mounted folder.

  1. First, go to /etc/fuse.conf, uncommented line
user_allow_other
  1. If you mount S3 bucket to folder using goofys , add -o allow-other option
./goofys -o allow_other --endpoint sgp1.digitaloceanspaces.com yourBucketName /mnt/yourBucketMountPoint/
  1. Then re-run docker-compose.yml file
    My Spaces Bucket

    My Spaces Bucket

Mounted Using Goofys on /mnt/test-nfs folder

Mounted Using Goofys on /mnt/test-nfs folder

Gohttpserver Running Successfully

Gohttpserver Running Successfully


Error You Might Face & The Solution

  1. s3.error http=501 not implemented
Error 501 was Because Your Credentials Wrong

Error 501 was Because Your Credentials Wrong

This mean you use wrong key, please recheck your S3 access key

  1. Transport endpoint is not connected
    Try to umount Your Folder

    Try to umount Your Folder

You should try to umount using sudo fusermount -u /mnt/test-nfs then try to mount again

  1. Error while creating mount source path
    Allow Other to Write at Mounted Folder

    Allow Other to Write at Mounted Folder

Change /etc/fuse.conf file, uncomment this line

user_allow_other

Jika kamu merasa tulisan ini bermanfaat & membantu kamu, kamu bisa berdonasi lewat saweria

If you feel this website help you, you can donate at saweria