gpt4 book ai didi

docker - 如何在Alpine容器中安装SSHFS?

转载 作者:行者123 更新时间:2023-12-02 21:09:27 25 4
gpt4 key购买 nike

我使用php:7.3.2-cli-alpine3.9作为我的基本图片。我还需要在容器内安装SSHFS,因为我使用的PHP库依赖于它。我知道“如果您在容器内安装SSHFS,您做错了”,有很多答案,但是就我而言,我需要将此软件安装在容器内而不是主机上。

在我的Dockerfile中
RUN apk update && apk add sshfs;
该命令执行无误:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
v3.9.3-21-g265a28802e [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.3-15-g583c0d55e9 [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
OK: 9764 distinct packages available
(1/12) Installing openssh-keygen (7.9_p1-r4)
(2/12) Installing openssh-client (7.9_p1-r4)
(3/12) Installing fuse-common (3.2.6-r1)
(4/12) Installing fuse3 (3.2.6-r1)
(5/12) Installing libffi (3.2.1-r6)
(6/12) Installing libintl (0.19.8.1-r4)
(7/12) Installing libuuid (2.33-r0)
(8/12) Installing libblkid (2.33-r0)
(9/12) Installing libmount (2.33-r0)
(10/12) Installing pcre (8.42-r1)
(11/12) Installing glib (2.58.1-r2)
(12/12) Installing sshfs (3.5.1-r0)
Executing busybox-1.29.3-r10.trigger
Executing glib-2.58.1-r2.trigger
OK: 25 MiB in 44 packages

但是当我尝试挂载远程主机时
'/usr/bin/sshfs' -C -o reconnect -o 'Port=22' -o 'UserKnownHostsFile=/ssh/known_hosts' -o StrictHostKeyChecking=yes -o 'IdentityFile=/ssh/<FILE>' -o PasswordAuthentication=no '<USER>@<HOST>:/' '/fuse/'
我正进入(状态:
fuse: device not found, try 'modprobe fuse' first
当我运行它时,我得到:
modprobe: can't change directory to '/lib/modules': No such file or directory
我是否缺少任何包裹?还需要安装什么?

谢谢。

最佳答案

为了在容器内运行SSHFS,它需要特权。

通过在Dockerfile中添加以下行来安装SSHFS:RUN apk update && apk add sshfs;
运行容器:docker run --privileged=true -it --rm --name alpine-app transfers-image

关于docker - 如何在Alpine容器中安装SSHFS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55696482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com