goofys-docker is a docker volume plugin wrapper for S3
The initial idea behind mounting s3 buckets as docker volumes is to provide store for configs and secrets. The volume as per goofys does not have features like random-write support, unix permissions, caching.
The docker host should have FUSE support with fusermount
cli utility in $PATH
There are prebuilt binaries availble here.
If you need to build it yourself there is a helper file build.sh
that will run a container that builds the application using go 1.8.
Example. Build binary for Linux with static linking
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -v -installsuffix cgo
Currently there is no support for configuration options, but the defaults are reasonable for most of the cases.
The most simple way to configure aws credentials is to use IAM roles to access the bucket for the machine, aws configuration file or ENV variables. The credentials will be used for all buckets mounted by goofys-docker
.
./goofys-docker
The socket /run/docker/plugins/goofys.sock
will be created to interact with docker. Ownership of the file is root:wheel
docker volume create --name=VOLUME_NAME --driver=goofys --opt OPTION
bucket
- Optional S3 bucket name. The default bucket is the volume name.prefix
- Optional S3 prefix path.region
- Optional AWS region (default is "us-east-1").debugs3
- Optional S3 debug logs (default is 0).
Create a new volume by issuing a docker volume command:
docker volume create --name=test-docker-goofys --driver=goofys region=eu-west-1
That will create a volume connected to test-docker-goofys
bucket. The region of the bucket will be autodetected.
Nothing is mounted yet.
Launch the container with test-docker-goofys
volume mounted in /home
inside the container.
docker run -it --rm -v test-docker-goofys:/home:ro -it busybox sh
/ # cat /home/test
test file content
/ # ^D
Pass the bucket name as an option instead of the default volume name value:
docker volume create --name=vol1 --driver=goofys --opt bucket=test-docker-goofys --opt region=eu-west-1
docker run -it --rm -v vol1:/home:ro -it busybox sh
/ # cat /home/test
test file content
/ # ^D
It is also possible to mount a subfolder:
docker volume create --name=vol1 --driver=goofys --opt prefix=folder region=eu-west-1
docker run -it --rm -v vol1:/home:ro -it busybox sh
/ # cat /home/test
test file content from folder
/ # ^D
If multiple folders are mounted for the single bucket on the same machine, only 1 fuse mount will be created. The mount will be shared by docker containers. It will be unmouned when there be no containers to use it.
MIT