Skip to content

Instantly share code, notes, and snippets.

@HeshamMeneisi
Last active September 13, 2023 21:47
Show Gist options
  • Save HeshamMeneisi/a3f96183cac25cf5979465b3cddef315 to your computer and use it in GitHub Desktop.
Save HeshamMeneisi/a3f96183cac25cf5979465b3cddef315 to your computer and use it in GitHub Desktop.
Mount S3 as Docker Volume (docker-compose)
# Tip: You can just define all environment variables used here in a
# .env file in the same directory so as not to expose secrets
# docker-compose will load it automatically
services:
s3fs:
privileged: true
image: efrecon/s3fs:1.86
restart: always
environment:
- AWS_S3_BUCKET=${AWS_S3_BUCKET}
- AWS_S3_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_S3_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
# A workaround for bucket names containing '.' until the related s3fs-fuse issue is resolved
# Keep in mind this is a secrutiy risk (default is https)
# - AWS_S3_URL=http://s3.amazonaws.com
volumes:
# This also mounts the S3 bucket to `/mnt/s3data` on the host machine
- /mnt/s3data:/opt/s3fs/bucket:shared
test:
build: .
restart: always
depends_on:
- s3fs
# Just so this container won't die and you can test the bucket from within
command: sleep infinity
volumes:
- /mnt/s3data:/data:shared
@vcombey
Copy link

vcombey commented Dec 21, 2020

doesn't work for me, it creates an empty folder in /mnt/s3data and in /data on the test container

@HeshamMeneisi
Copy link
Author

HeshamMeneisi commented Dec 22, 2020

You can try to set "- S3FS_DEBUG=${DEBUG}" to see what's happening.

My best guess is permission issues. You can try something other than /mnt/s3data if docker doesn't have access to /mnt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment