s3-fuse docker运行试用
s3-fuse 是一个很不错的基于fuse 暴露s3 数据为标准文件系统数据的扩展,以前有基于rpm包运行的demo
以下是基于docker-compose运行demo
一个参考案例
环境准备
- docker-compose文件
version: "3"
services:
minio:
image: minio/minio:RELEASE.2020-04-04T05-39-31Z
environment:
- "MINIO_ACCESS_KEY=minio"
- "MINIO_SECRET_KEY=minio123"
- "MINIO_BROWSER=off"
command: server /data
ports:
- "80:9000"
gateway:
image: minio/minio:RELEASE.2020-04-04T05-39-31Z
command: gateway s3 http://minio:9000
ports:
- "9000:9000"
environment:
- "MINIO_ACCESS_KEY=minio"
- "MINIO_SECRET_KEY=minio123"
app:
image: dalongrong/s3-fs:1.86
privileged: true
environment:
- "AWS_KEY=minio"
- "AWS_SECRET_KEY=minio123"
- "S3_REGION=us-east-1"
- "S3_URL=http://minio:9000"
- "S3_BUCKET=apps"
volumes:
- "./s3:/var/s3"
- s3-fs Dockerfile
###############################################################################
# The FUSE driver needs elevated privileges, run Docker with --privileged=true
###############################################################################
FROM alpine:3.3
ENV MNT_POINT /var/s3
ENV S3_REGION ''
ARG S3FS_VERSION=v1.86
RUN apk --update --no-cache add fuse alpine-sdk automake autoconf libxml2-dev fuse-dev curl-dev git bash; \
git clone https://github.com/s3fs-fuse/s3fs-fuse.git; \
cd s3fs-fuse; \
git checkout tags/${S3FS_VERSION}; \
./autogen.sh; \
./configure --prefix=/usr; \
make; \
make install; \
make clean; \
rm -rf /var/cache/apk/*; \
apk del git automake autoconf;
RUN mkdir -p "$MNT_POINT"
CMD echo "${AWS_KEY}:${AWS_SECRET_KEY}" > /etc/passwd-s3fs && \
chmod 600 /etc/passwd-s3fs && \
/usr/bin/s3fs $S3_BUCKET $MNT_POINT -f -o url=${S3_URL},endpoint=${S3_REGION},allow_other,use_path_request_style,retries=5,connect_timeout=10
使用说明
- 启动minio
docker-compose up -d minio
- 按需启动gateway
gateway 主要是ui 的 - 创建bucket以及上传测试文件
- 启动s3-fuse 服务
docker-compose up -d app
查看内容
容器内部:
docker-compose exec app sh
ls /var/s3
效果
说明
我们基于s3-fuse,可以方便的进行不同容器的数据共享,实际上docker 也提供了基于s3 volume plugin,有点不是很好的地方是需要一些比较高的
权限
参考资料
https://github.com/rongfengliang/minio-s3-fuse-docker-compose-learning
https://github.com/s3fs-fuse/s3fs-fuse
https://github.com/freegroup/kube-s3