Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run command podman -v /source_volume:/container_dir and it throw an error Error: statfs /source_volume: no such file or directory #14781

Closed
geekerNo1 opened this issue Jun 30, 2022 · 14 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@geekerNo1
Copy link

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description
Accodring to doc https://docs.podman.io/en/latest/markdown/podman-run.1.html. Podman -v will mount the source volume to container dir. If no such named volume exists, podman will create one.
But when I mount an volume which is not exists, it will throw an error, "Error: statfs /volume_dir: no such file or directory"

Steps to reproduce the issue:

  1. podman run -it --volume /tmp/abcd:/tmp/test --name "test" <container_name>
    Error: statfs /tmp/abcd: no such file or directory
  2. podman run -it -v /tmp/abcd:/tmp/test --name "test" <container_name>
    Error: statfs /tmp/abcd: no such file or directory

Output of podman version:

podman version 4.0.2
@openshift-ci openshift-ci bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 30, 2022
@flouthoc
Copy link
Collaborator

flouthoc commented Jun 30, 2022

Hi @geekerNo1 Thanks for creating the issue.

In following command --volume /tmp/abcd:/tmp/test the volume source does not looks like name to volume but instead looks like a path on host where user is making an attempt towards creating bind mount inside container. The documentation states true if you attempt to mount a podman volume so something like --volume my-vol:/tmp/test should automatically create podman volume if it does not exists and you can further verify using podman volume ls.

I am not sure if podman should attempt to create a named volume where name actually looks like a path on host since this could lead to scenarios where podman run will confuse it user is requesting a path on host or a named volume which looks like path.

Tagging @containers/podman-maintainers for input here.

@geekerNo1
Copy link
Author

geekerNo1 commented Jun 30, 2022

Hi @flouthoc Thanks for you reply.

/tmp/abcd is a path on host, not a volume. I confuse those two. Sorry about that mistake.

I attempt to use podman instead of docker on rhel8. I want to use command podman -v /tmp/abcd:/tmp/test to instead of docker command docker -v /tmp/abcd:/tmp:test.
If the path /tmp/test is not exists on host

  1. run command podman -v /tmp/abcd:/tmp/test, it will throw an error Error: statfs /tmp/abcd: no such file or directory.
  2. run command docker -v /tmp/abcd:/tmp/abcd, it will automatically creates the dir on host.

So I guess that this is a difference between docker and podman, right?
Looking forward to your reply

@flouthoc
Copy link
Collaborator

@geekerNo1 Thanks for making it clear. I can also confirm docker creates path on host if it does not exists and i think in such case podman should do the same.

@giuseppe
Copy link
Member

I think the Podman behavior is saner. It helps to find out typos more easily. e.g. something like mkdir /tmp/foo; podman run -v /tmp/fo:/foo ... would not be easily detected if Podman would automatically create the directory.

@Luap99
Copy link
Member

Luap99 commented Jun 30, 2022

This was discussed before and we (Podman maintainers) think this is a bug. What if you have a typo now podman creates a new empty directory and does not use the one you intended or what if you want to bind mount a file and the file simply does not exists?

@Luap99
Copy link
Member

Luap99 commented Jun 30, 2022

Also see #10471 and #6234
I know that there are more issues with more discussion about this but I cannot find them right now.

Anyway this is something we decided not to do.

@Luap99 Luap99 closed this as completed Jun 30, 2022
@vrothberg
Copy link
Member

vrothberg commented Jun 30, 2022

This was discussed before and we (Podman maintainers) think this is a bug. What if you have a typo now podman creates a new empty directory and does not use the one you intended or what if you want to bind mount a file and the file simply does not exists?

All of them are closed and the docs seem to be wrong. I suggest reopening and reflecting the reasoning in the docs.

@Luap99
Copy link
Member

Luap99 commented Jun 30, 2022

Which docs are you talking about? I see this:

From https://docs.podman.io/en/latest/markdown/podman-run.1.html#volume-v-source-volume-host-dir-container-dir-options

If the source does not exist, Podman will return an error. Users must pre-create the source files or directo‐
ries.

@flouthoc
Copy link
Collaborator

This was discussed before and we (Podman maintainers) think this is a bug.

Ah i see but I don't think this is bug at docker end but more like expected behavior on the docker side. The docs here mention this behavior https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only

"When the host directory of a bind-mounted volume doesn’t exist, Docker will automatically create this directory on the host for you"

But reasoning here makes sense to me: #6234 (comment)

@vrothberg
Copy link
Member

Which docs are you talking about? I see this:

From https://docs.podman.io/en/latest/markdown/podman-run.1.html#volume-v-source-volume-host-dir-container-dir-options

If the source does not exist, Podman will return an error. Users must pre-create the source files or directo‐
ries.

See the issue description. The doc also states "If no such named volume exists, Podman will create one". The two conflict and if users look for that information they will very likely stop reading at some point.

@rhatdan
Copy link
Member

rhatdan commented Jun 30, 2022

Podman is working correctly. We should NOT create the source directory. Docker might do this but I see it as a bug.
Would you expect mount -o bind /tmp/abcd /mnt to create /tmp/abcd?

If the docs say that we create the source directory then the docs need to be fixed.
If Docker has bad design or what we feel is clearly a bug easily remedied by the user, then we should not implement the bug for compatibility purposes.

@vrothberg vrothberg reopened this Jun 30, 2022
@vrothberg
Copy link
Member

Reopening as the docs should be less confusing.

@geekerNo1
Copy link
Author

Thanks all helps! Now I got it. Close the issue.

@domdomegg
Copy link
Contributor

(duplicate of #6234)

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Oct 18, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

7 participants