Mac OS 中 Podman 挂载主机卷返回“错误:statfs:没有此类文件或目录”

问题描述 投票:0回答:4

最近从 Docker Desktop 切换到 Podman,一切都很顺利,除了当我想将主机卷挂载到容器中时。例如

➜  ~ podman run --name nginx -v ~/bin/nginx/nginx.conf:/etc/nginx/nginx.conf:ro -d -p 8080:80 nginx
Error: statfs /Users/rb/bin/nginx/nginx.conf: no such file or directory

➜  ~  ls -lt ~/bin/nginx/nginx.conf                                                                 
-rw-r--r--  1 rb staff  490 Apr 23 14:31 /Users/rb/bin/nginx/nginx.conf

host文件

~/bin/nginx/nginx.conf
确实存在,那么这里有什么问题呢?

mount podman
4个回答
9
投票

尝试以下操作:

  1. 重启虚拟机:

    podman machine stop; podman machine start
    

    正如 @rafagarci 在评论中提到的,有时新启动失败,您应该再次运行这些命令几次。

    然后安装(

    -v
    )就可以了。

  2. 如果重新启动不起作用,请尝试重新创建您的 podman 机器

    podman machine stop
    podman machine rm
    podman machine init # you may specify parameters for your VM
    podman machine start
    

    文档中,您可以找到

    podman machine init
    命令的参数。


9
投票

在 podman 4.5.1 上,这不再是问题,默认的 Podman 机器已经在 macOS 中安装了

/Users
/private
/var/folders

如果您收到

Error: statfs /Users/xxxxx/yyyy  : no such file or directory
,这可能是一个临时错误

podman machine stop
podman machine start
Waiting for VM ...
Mounting volume... /Users:/Users
Mounting volume... /private:/private
Mounting volume... /var/folders:/var/folders

之后你应该能够在 /Users 下安装任何东西

podman run -ti --rm -v "$HOME:/myhome" ubi8 
[root@ba2054e82401 /]# ls /myhome

仅将

podman machine rm
作为最后的手段,因为这会删除您的容器和下载的图像等。


8
投票

在 MacO 上也遇到同样的问题。

当使用的挂载点不是来自主机本身,而是来自 podman 虚拟机时,我修复了这个问题。

首先我将主机卷安装到 podman vm:

podman machine init -v $HOST_VOLUME:/mnt/$PODMAN_VM_VOLUME

之后将 PODMAN_VM_VOLUME 挂载到 CONTAINER_VOLUME:

podman run -d -it --name test -v /mnt/$PODMAN_VM_VOLUME:/$CONTAINER_VOLUME

0
投票

除了在 podman 机器 init 上安装卷之外,我还必须运行:

podman machine set --rootful podman-machine-default

然后它对我来说适用于 Compose 的 yaml 文件。

© www.soinside.com 2019 - 2024. All rights reserved.