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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM