mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2026-04-25 13:26:00 +03:00
[GH-ISSUE #1610] Dockerfile build error #848
Labels
No labels
bug
bug
dataloss
duplicate
enhancement
feature request
help wanted
invalid
need info
performance
pull-request
question
question
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/s3fs-fuse#848
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pgb6 on GitHub (Mar 25, 2021).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/1610
Version of s3fs being used (s3fs --version)
(Inside docker container, if I comment out s3 command and lines after in Dockerfile)
Amazon Simple Storage Service File System V1.89 (commit:ef079f4) with OpenSSL
Version of fuse being used (pkg-config --modversion fuse, rpm -qi fuse, dpkg -s fuse)
(Inside docker container, if I comment out s3 command and lines after in Dockerfile)
2.9.9
Kernel information (uname -r)
(Inside docker container, if I comment out s3 command and lines after in Dockerfile)
5.4.72-microsoft-standard-WSL2
GNU/Linux Distribution, if applicable (cat /etc/os-release)
(Inside docker container, if I comment out s3 command and lines after in Dockerfile)
NAME="Ubuntu"
VERSION="20.10 (Groovy Gorilla)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.10"
VERSION_ID="20.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=groovy
UBUNTU_CODENAME=groovy
Details about issue
I wanted to use s3fs so that the outputs of my python script could go directly to an S3 bucket via a mount on a Docker containers' directory (I know I can use boto3 in my script, but I'm not sure why this isn't working).
This is my dockerfile:
Running docker build on this dockerfile results in :
And if I follow the suggestion and include 'RUN modprobe fuse' before this line in the Dockerfile, the build will fail with a 'modprobe not found' error. However, if I erase all the line below and including the dockerfile s3fs command, and ssh into the running container, I am able to run the s3fs command. Only then, can I see the mount in 'df -h'.
I am not well-versed in Docker, so I suspect I may be misusing s3fs in this case.
@FANMixco commented on GitHub (Apr 8, 2021):
I´m facing the same issue while building the dockerfile. Did you find how to fix it @pgb6?
@pgb6 commented on GitHub (Apr 8, 2021):
@FANMixco I couldn't find out how to fix it, so I just used the boto3 SDK instead of s3fs. I assumed it may just be a problem with the inner workings of s3fs itself. What else did you try to debug the issue?
@gaul commented on GitHub (Apr 8, 2021):
This isn't an s3fs-specific issue and would occur with any FUSE filesystem like sshfs. You need to configure your Docker container properly to access fuse. Unfortunately I can't help you with this.
@weisdd commented on GitHub (Apr 10, 2021):
On Ubuntu, you can pass the following options to docker to give it access to fuse:
--cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfinedE.g.
docker run --rm -it --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined alpineThe same set of options should work for docker build as well, though it doesn't make much sense to do so. s3fs process will be terminated once the build is completed. You should move this logic to your entrypoint script.
@FANMixco commented on GitHub (Apr 13, 2021):
Hi @weisdd , it didn´t work:
@weisdd commented on GitHub (Apr 13, 2021):
@FANMixco yeah, you're right, it's not there for build. But anyway, there's no reason to keep
RUN s3fs $S3_BUCKET_NAME $S3_MOUNT_DIRECTORYin Dockerfile as well as many other things. If you really need to mount a bucket for your script to work, s3fs has to be called during runtime (docker run ...), not during build. And you can pass the options described above todocker run.@pgb6 commented on GitHub (Apr 13, 2021):
@weisdd Could you explain why there's no reason to run the command in the Dockerfile? For use-cases like AWS ECS, it wouldn't make sense to run the container and then SSH into it to run the mount command--in this case, everything should be automated after the container is built and run.
@weisdd commented on GitHub (Apr 13, 2021):
@pgb6 Sure. :)
Just imagine that you have an EC2 virtual machine and you want to run an nginx. You install the package, but forget to instruct systemd to automatically start the daemon. So, after a reboot, you do have nginx, though it's not running.
With your Dockerfile, you have something similar. - When you mount a bucket through s3fs without
-f(foreground) flag, there's a new process running in background (=daemon). If the process dies for some reason, you can't work with the files as there's nothing to translate system calls to S3-specific HTTP requests anymore.Docker build is needed to prepackage an image. The processes you run during the build stage are not carried to the run stage, they all exit by the end of the build. Thus, when you run a new container with the image, there's no s3fs daemon anymore. You have to call it in an entrypoint script, and then exec into your python script (an example).
I'd recommend you to google an introduction to Docker (there should be hundreds of decent articles and plenty of great books on the Internet) to get an idea of how containers are different from virtual machines. Just an hour or two would be enough to start. Keep going :)
As a side note, to me, s3fs seems to be an overkill here. Yet, that's another question :)
@gaul commented on GitHub (Apr 14, 2021):
It would be great if someone from the community could write up documentation, e.g., a wiki page, that we can point users to for common Docker issues and maybe add a blurb in the README. There are also a diversity of s3fs Docker projects that all seem similar to me. Ideally we could promote one or two of the higher-quality ones in the s3fs README.
Unfortunately the s3fs maintainers (including me) lack sufficient container/Docker background to help with these issues. Please help out if you can!
@FANMixco commented on GitHub (Apr 15, 2021):
I added it as an entry point and got a different error:
Example:
ENTRYPOINT ["s3fs", "cpoa-test", "/home/app/logs", "-o", "dbglevel=info"]@FANMixco commented on GitHub (Apr 16, 2021):
Hi @pgb6, I made it work like in this answer:
https://stackoverflow.com/a/67129918/1928691
@pgb6 commented on GitHub (Apr 16, 2021):
@weisdd thank you so much for this answer! It definitely helped improve my understanding of the issue here :)
@pgb6 commented on GitHub (Apr 16, 2021):
@FANMixco Wow, this is also extremely helpful. Thank you for this--I will close the issue now since it works!! Cheers.
@weisdd commented on GitHub (Apr 17, 2021):
@FANMixco it's actually a bad example. I'll try to explain why:
s3fs runs in background by default, so you don't actually need to use
&.If you run an app like that, it won't be receiving signals. Thus, it would not stop gracefully if you send a SIGTERM.
In Kubernetes, for instance, you'll see the app not reacting to SIGTERM for 30 seconds (default timeout), and then the app will be killed by SIGKILL. The same applies for
docker stop.There are two options here: either write traps or just exec into the app. The latter would look like:
Not sure about background tasks with s3fs, maybe signal propagation will just work or traps are required. - Needs testing.
@FANMixco commented on GitHub (Apr 17, 2021):
Hi @weisdd. Thanks for your ideas, but the reason is simple: Business requirements. I'm unauthorized to change any of the JARs. I have to sync the logs folder with the S3 but I cannot change the JARs logic.
@weisdd commented on GitHub (Apr 17, 2021):
@FANMixco there's no modification for jars, they just start through
exec. More details here.@FANMixco commented on GitHub (Apr 19, 2021):
@weisdd. It happens in my specific business case. However, if you use Docker-compose it doesn't happen the sh trouble.