LoginSignup
17
17

More than 5 years have passed since last update.

【質問エントリ】s3fsってdocker内でマウントできないの?

Last updated at Posted at 2014-07-27

StackOverFlowでも解決できなかったのでQiitaに望みをかけて…。

dockerコンテナの中でs3fsをマウントしたいと思っています。
s3fsをコンパイルしたdockerイメージを作成して、以下のようにやってみたのですが、

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

"Operation not permitted" というfuseのエラーが出てマウントできませんでした。

ググってみたところ、docker内でfuseを使うには --privileged=true というオプションを付けないといけないという情報があったので、以下のように再挑戦してみましたが、

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コマンド等何か操作しようとすると、 "Transport endpoint is not connected" というエラーが出るようになりました。
このエラーは一度アンマウントして再マウントすると出なくなる、という情報もあったのですが、結果は上記の通り再マウントを繰り返してもダメでした。

s3fsをdockerコンテナ内でマウントするにはどうすればよいのでしょうか?
そもそも無理なのでしょうか?

[追記]

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

passwd-s3fsはもちろんS3接続の設定ファイルです。
rules.d/99-fuse.rulesとかいうのは、この辺のエラーを調べていた際に加えた方がよいとどこかで見たファイルです。
あまり意味は判ってません。

rules.d/99-fuse.rules
KERNEL==fuse, MODE=0777
17
17
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
17