2014-07-26 44 views
5

Tôi muốn gắn kết s3fs bên trong thùng chứa docker.S3fs không thể gắn bên trong thùng chứa docker?

tôi đã thực hiện hình ảnh Docker với s3fs, và đã làm như thế này:

host$ docker run -it --rm docker/s3fs bash 
[ [email protected]:~ ]$ 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 

Hiển thị "hoạt động không được phép" lỗi.

Vì vậy, tôi googled, và đã làm như thế này (thêm --privileged = true) một lần nữa:

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

Sau đó, gắn không thấy lỗi, nhưng nếu chạy ls lệnh, "Giao thông vận tải thiết bị đầu cuối không được kết nối" lỗi đã xảy ra.

Làm cách nào để gắn kết s3fs bên trong vùng chứa docker? Có thể không?

[CẬP NHẬT]

Thêm cấu hình 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:

KERNEL==fuse, MODE=0777 

Trả lời

6

Tôi không chắc chắn những gì bạn đã điều đó không làm việc, nhưng tôi đã có thể có được điều này để làm việc như thế này:

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 

Sau khi xây dựng với:

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

Tôi chạy container với:

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

và sau đó bên trong container:

[email protected]:/# s3fs s3bucket /s3bucket 
[email protected]:/# ls /s3bucket 
testing.this.out work.please working 
[email protected]:/# 

mà niêm yết thành công các tập tin trong S3Bucket tôi.

Bạn cần đảm bảo hạt nhân trên máy chủ của bạn hỗ trợ cầu chì, nhưng có vẻ như bạn đã làm như vậy?

Lưu ý: Điểm gắn S3 của bạn sẽ không hiển thị/làm việc từ bên trong các vùng chứa khác khi sử dụng chỉ thị của Docker --volume hoặc --volumes-from. Ví dụ:

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 .. 

không trả về tệp nào mặc dù có tệp trong thùng.

+1

Cảm ơn bạn! Tôi kiểm tra thủ tục của bạn, nó hoạt động như sự quyến rũ. Nhưng cũng như, như bạn nói, nó không thể gắn kết từ các container khác ... Có cách nào để sử dụng nó từ các container khác? – kochizufan

+5

'--privileged' là những gì hiện nó, tiếc là điều này chỉ hoạt động trong giai đoạn chạy và không phải là giai đoạn xây dựng. – buley

Các vấn đề liên quan