25

Recently switched from Docker Desktop to Podman, everything work smoothly except when I want to mount host volume into container. e.g.

➜  ~ 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

The host file ~/bin/nginx/nginx.conf do exist, so what's the problem here?

3

4 Answers 4

11

Try the following:

  1. Restart of VM:

    podman machine stop; podman machine start
    

    As @rafagarci mentioned in comments, sometimes new start failed and you should run these commands again a few times.

    Then mount (-v) works fine.

  2. If restart doesn't help then try to recreate your podman machine:

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

    In documentation you may find parameters for podman machine init command.

1
  • 1
    I had to stop and re-start podman multiple times until it successfully mounted my machine's directories.
    – rafagarci
    Jun 26 at 8:33
9

On podman 4.5.1 this should not be an issue anymore , the default Podman machine already mounts /Users, /private and /var/folders in macOS.

If you are getting Error: statfs /Users/xxxxx/yyyy : no such file or directory it's probably a temporary error do

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

After that you should be able to mount anything under /Users

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

Only do podman machine rm as a last resort, because that will delete your containers, and downloaded images, etc.

1
  • 1
    Guess what, with podman 4.7.1 the issue came back... or to me more precise with fedora-core-39 podman machine as is the one that seems to be downloaded. Might be github.com/containers/podman/issues/20081 bug
    – sorin
    Nov 9 at 15:07
8

Had the same problem on MacOs.

I fixed it when used mount point not from the host machine itself, but from podman virtual machine.

So firstly i mounted the host volume to podman vm:

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

And after that mounted PODMAN_VM_VOLUME to CONTAINER_VOLUME:

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

Apart from mounting a volume at the podman machine init I had to additionally run:

podman machine set --rootful podman-machine-default

and then it worked for me for a yaml file with Compose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.