Mount an S3 bucket as an NFS filesystem so it can be used as a Docker or Docker Compose volume.
The example Compose manifest will start the s3-nfs container on localhost port 2049.
It will then make the NFS filesystem available to other services by configuring it as a volume.
The service_healthy condition ensures that a connection to the bucket is successfully established before the other services will start using it.
Multiple services can use the same volume.
wget -q https://raw.githubusercontent.com/nedix/s3-nfs-container/main/examples/compose.ymldocker compose up -ddocker compose exec busybox ls /dataThe following example mounts a bucket to a local directory named s3-nfs.
docker run \
--cap-add SYS_ADMIN \
--device /dev/fuse \
--name s3-nfs \
--pull always \
--restart unless-stopped \
-e S3_ACCESS_KEY_ID="qux" \
-e S3_BUCKET="baz" \
-e S3_ENDPOINT="foo" \
-e S3_REGION="bar" \
-e S3_SECRET_ACCESS_KEY="quux" \
-p 127.0.0.1:2049:2049 \
nedix/s3-nfsmkdir s3-nfsmount -v -o vers=4 -o port=2049 127.0.0.1:/ ./s3-nfs