s3fs无法挂载到Docker容器中吗? [英] Is s3fs not able to mount inside docker container?

查看:303
本文介绍了s3fs无法挂载到Docker容器中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将s3fs安装在docker容器中.

I want to mount s3fs inside of docker container.

我用s3fs制作了docker镜像,并且这样做:

I made docker image with s3fs, and did like this:

host$ docker run -it --rm docker/s3fs bash
[ root@container:~ ]$ s3fs s3bucket /mnt/s3bucket -o allow_other -o allow_other,default_acl=public-read -ouse_cache=/tmp
fuse: failed to open /dev/fuse: Operation not permitted

显示不允许操作"错误.

Showing "Operation not permitted" error.

所以我用谷歌搜索,并再次这样做(添加--privileged = true):

So I googled, and did like this (adding --privileged=true) again:

host$ docker run -it --rm --privileged=true docker/s3fs bash
[ root@container:~ ]$ s3fs s3bucket /mnt/s3bucket -o allow_other -o allow_other,default_acl=public-read -ouse_cache=/tmp
[ root@container:~ ]$ ls /mnt/s3bucket
ls: cannot access /mnt/s3bucket: Transport endpoint is not connected
[ root@container:~ ]$ fusermount -u /mnt/s3bucket
[ root@container:~ ]$ s3fs s3bucket /mnt/s3bucket -o allow_other -o allow_other,default_acl=public-read -ouse_cache=/tmp
[ root@container:~ ]$ ls /mnt/s3bucket
ls: cannot access /mnt/s3bucket: Transport endpoint is not connected

然后,安装未显示错误,但是如果运行ls命令,则发生传输端点未连接"错误.

Then, mounting not shows error, but if run ls command, "Transport endpoint is not connected" error is occured.

如何将s3fs安装在Docker容器中? 不可能吗?

How can I mount s3fs inside of docker container? Is it impossible?

[更新]

添加Dockerfile配置.

Add Dockerfile configuration.

Dockerfile:

Dockerfile:

FROM dockerfile/ubuntu

RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y libfuse-dev
RUN apt-get install -y fuse
RUN apt-get install -y libcurl4-openssl-dev
RUN apt-get install -y libxml2-dev
RUN apt-get install -y mime-support

RUN \
  cd /usr/src && \
  wget http://s3fs.googlecode.com/files/s3fs-1.74.tar.gz && \
  tar xvzf s3fs-1.74.tar.gz && \
  cd s3fs-1.74/ && \
  ./configure --prefix=/usr && \
  make && make install

ADD passwd/passwd-s3fs /etc/passwd-s3fs
ADD rules.d/99-fuse.rules /etc/udev/rules.d/99-fuse.rules
RUN chmod 640 /etc/passwd-s3fs

RUN mkdir /mnt/s3bucket

rules.d/99-fuse.rules:

rules.d/99-fuse.rules:

KERNEL==fuse, MODE=0777

推荐答案

我不确定您所做的那没有用,但是我能够使它像这样工作:

I'm not sure what you did that did not work, but I was able to get this to work like this:

Dockerfile:

Dockerfile:

FROM ubuntu:12.04

RUN apt-get update -qq
RUN apt-get install -y build-essential libfuse-dev fuse-utils libcurl4-openssl-dev libxml2-dev mime-support automake libtool wget tar

RUN wget https://github.com/s3fs-fuse/s3fs-fuse/archive/v1.77.tar.gz -O /usr/src/v1.77.tar.gz
RUN tar xvz -C /usr/src -f /usr/src/v1.77.tar.gz
RUN cd /usr/src/s3fs-fuse-1.77 && ./autogen.sh && ./configure --prefix=/usr && make && make install

RUN mkdir /s3bucket

构建后:

docker build --rm -t ubuntu/s3fs:latest .

我用以下方法运行容器:

I ran the container with:

docker run -it -e AWSACCESSKEYID=obscured -e AWSSECRETACCESSKEY=obscured --privileged ubuntu/s3fs:latest bash

然后在容器内:

root@efa2689dca96:/# s3fs s3bucket /s3bucket
root@efa2689dca96:/# ls /s3bucket
testing.this.out  work.please  working
root@efa2689dca96:/#

成功列出了我的s3bucket中的文件.

which successfully listed the files in my s3bucket.

您确实需要确保主机上的内核支持保险丝,但是看来您已经这样做了?

You do need to make sure the kernel on your host machine supports fuse, but it would seem you have already done so?

注意:当使用Docker的--volume或--volumes-from指令时,您的S3挂载点将不会在其他容器中显示/工作.例如:

Note: Your S3 mountpoint will not show/work from inside other containers when using Docker's --volume or --volumes-from directives. For example:

docker run -t --detach --name testmount -v /s3bucket -e AWSACCESSKEYID=obscured -e AWSSECRETACCESSKEY=obscured --privileged --entrypoint /usr/bin/s3fs ubuntu/s3fs:latest -f s3bucket /s3bucket
docker run -it --volumes-from testmount --entrypoint /bin/ls ubuntu:12.04 -ahl /s3bucket
total 8.0K
drwxr-xr-x  2 root root 4.0K Aug 21 21:32 .
drwxr-xr-x 51 root root 4.0K Aug 21 21:33 ..

即使存储桶中有文件,也不返回文件.

returns no files even though there are files in the bucket.

这篇关于s3fs无法挂载到Docker容器中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆