cgwalters / coretoolbox

"pet container" tool using podman
Apache License 2.0
24 stars 6 forks source link

error: Initializing container: Child ["mount" "--bind" "/host/home/<user>" "/home/<user>"] #3

Open juhp opened 5 years ago

juhp commented 5 years ago

In Fedora 29 and also Silverblue 30 when I initially run coretoolbox, I see:

$ git clone https://github.com/cgwalters/coretoolbox
$ cd coretoolbox
$ cargo build
$ ./target/debug/coretoolbox 
Trying to pull docker://registry.fedoraproject.org/f30/fedora-toolbox:30...Getting image source signatures
Copying blob 934966bfd3bd done
Copying blob cd73137bf7d1 done
Copying config dbfb7129d3 done
Writing manifest to image destination
Storing signatures
dbfb7129d38b39508dab2878f108ff50759087100bfd9b08d0539e7a3de7cce3
coreos-toolbox
mount: /home/petersen: wrong fs type, bad option, bad superblock on /host/home/petersen, missing codepage or helper program, or other error.
error: Initializing container: Child ["mount" "--bind" "/host/home/petersen" "/home/petersen"] exited: exit code: 32
Error: exit status 1

Second run of coretoolbox gives:

$ ./target/debug/coretoolbox 
12b97d1dd6bd74d7550a0b89a3b9398512dab200701d54fb95e9d9caa83a709e
error: Initializing container: Opening statefile: No such file or directory (os error 2)
Error: exit status 1
juhp commented 5 years ago

(I don't have a home partition if that makes a difference.)

cgwalters commented 5 years ago

Hmm, probably the bug is around how we're passing --volume for podman. Will look.

juhp commented 5 years ago

I don't see that any more with the latest code.

juhp commented 5 years ago

So actually this issue seems to be the real problem I hit.

Using --rbind seems to fix/workaround the problem for me.

diff --git a/src/coretoolbox.rs b/src/coretoolbox.rs
index 943d275..aa43e81 100644
--- a/src/coretoolbox.rs
+++ b/src/coretoolbox.rs
@@ -374,7 +374,7 @@ mod entrypoint {
         nix::unistd::chown(state.home.as_str(), Some(uid), Some(gid))?;
         let host_home = format!("/host{}", state.home);
         Command::new("mount")
-            .args(&["--bind", host_home.as_str(), state.home.as_str()])
+            .args(&["--rbind", host_home.as_str(), state.home.as_str()])
             .run()?;
         Ok(())
     }
cgwalters commented 5 years ago

Using --rbind seems to fix/workaround the problem for me.

Thanks! Indeed as a general rule we should use rbind. Mind doing a PR so you get credit?

cgwalters commented 5 years ago

Although, I think what we're doing here with /home and /var/home on the host/container is still messy. We probably need to ensure the container matches up with whether the homedir is /home or /var/home on the host.

cgwalters commented 5 years ago

(But that can be fixed separately)

HarryMichal commented 4 years ago

Hi, just tried to run coretoolbox and I'm hitting an issue very similar to this one. Here's what I've got:

omichal@harry-work debug ±(master) $ ./coretoolbox create -I fedora-toolbox:30
omichal@harry-work debug ±(master) $ ./coretoolbox run
mount: /var/home/omichal: special device /host/home/omichal does not exist.
error: Initializing container (static): Child ["mount" "--rbind" "/host/home/omichal" "/home/omichal"] exited: exit code: 32
Error: non zero exit code: 1: OCI runtime error
omichal@harry-work debug ±(master) $ ./coretoolbox run
error: Initializing container (static): Not a directory (os error 20)
Error: non zero exit code: 1: OCI runtime error
omichal@harry-work debug ±(master) $
debarshiray commented 4 years ago

I'm hitting an issue very similar to this one. Here's what I've got:

omichal@harry-work debug ±(master) $ ./coretoolbox create -I fedora-toolbox:30
omichal@harry-work debug ±(master) $ ./coretoolbox run
mount: /var/home/omichal: special device /host/home/omichal does not exist.
error: Initializing container (static): Child ["mount" "--rbind" "/host/home/omichal" "/home/omichal"] exited: exit code: 32
Error: non zero exit code: 1: OCI runtime error
omichal@harry-work debug ±(master) $ ./coretoolbox run
error: Initializing container (static): Not a directory (os error 20)
Error: non zero exit code: 1: OCI runtime error
omichal@harry-work debug ±(master) $

Yes, I am getting the same with podman-1.7.0-0.4.rc2.fc31.x86_64

cgwalters commented 4 years ago

Can you paste the output of:

echo $HOME
ls -al $HOME
findmnt $HOME
Siosm commented 4 years ago

I am hitting the same issue on a Fedora Workstation 31 with podman-1.8.0-2.fc31.x86_64:

$ coretoolbox run
mount: /home/tim: special device /host/home/tim does not exist.
error: Initializing container (static): Child ["mount" "--rbind" "/host/home/tim" "/home/tim"] exited: exit code: 32
Error: non zero exit code: 1: OCI runtime error
$ echo $HOME
/home/tim
$ ls -alhd $HOME
drwx------. 28 tim tim 4.0K Feb 24 12:31 /home/tim
$ findmnt $HOME
<no output here>
$ findmnt /home
TARGET SOURCE         FSTYPE OPTIONS
/home  /dev/nvme0n1p4 ext4   rw,relatime,seclabel

I have not yet investigated further.