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

cannot bind mount in container #65

Closed
InformatiQ opened this issue Jun 29, 2015 · 7 comments
Closed

cannot bind mount in container #65

InformatiQ opened this issue Jun 29, 2015 · 7 comments

Comments

@InformatiQ
Copy link

trying to start a container with a bind mount
it failes with error

Timestamp: 2015-06-29 14:24:38.112196007 +0200 CEST
Code: System error

Message: no such device

Frames:

---
0: setupRootfs
Package: github.com/opencontainers/runc/libcontainer
File: rootfs_linux.go@37

---
1: Init
Package: github.com/opencontainers/runc/libcontainer.(*linuxStandardInit)
File: standard_init_linux.go@52

---
2: StartInitialization
Package: github.com/opencontainers/runc/libcontainer.(*LinuxFactory)
File: factory_linux.go@242

---
3: init·1
Package: main
File: main.go@36

---
4: init
Package: main
File: utils.go@173

---
5: main
Package: runtime
File: proc.go@58

---
6: goexit
Package: runtime
File: asm_amd64.s@2232
WARN[0000] exit status 1                                
FATA[0000] Container start failed: [8] System error: no such device 

this is the added part apart from the default spec + user modification
{
"type": "bind",
"source": "/home/user",
"destination": "/home/user",
"options": ""
}

@GeertJohan
Copy link

Please don't just paste some logs into an issue. Especially not when they contain markdown directives. Put the logs between tripple backticks: ``` to let the logs render in a nice way.

@InformatiQ
Copy link
Author

I actually found the issue
i needed to add 'bind' in the 'options'
{
"type": "bind",
"source": "/home/user",
"destination": "/home/user",
"options": "bind"
}
not sure if this is a bug, but i would have expected type: bind to imply a bind mount

@rajasec
Copy link
Contributor

rajasec commented Jun 29, 2015

Currently it has the bind option supported as per the code.

Can you check whether your new directory is created inside your rootfs ?

if err := createIfNotExists(dest, stat.IsDir()); err != nil {
return err
}
if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data); err != nil {
return err
}
if m.Flags&syscall.MS_RDONLY != 0 {
if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags|syscall.MS_REMOUNT), ""); err != nil {
return err
}
}
if m.Relabel != "" {
if err := label.Relabel(m.Source, mountLabel, m.Relabel); err != nil {
return err
}
}
if m.Flags&syscall.MS_PRIVATE != 0 {
if err := syscall.Mount("", dest, "none", uintptr(syscall.MS_PRIVATE), ""); err != nil {
return err
}
}

@rajasec
Copy link
Contributor

rajasec commented Jun 29, 2015

It is failing in the following call during the mount
if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data); err != nil

@rajasec
Copy link
Contributor

rajasec commented Jun 30, 2015

I could solve the problem via the code by adding MS_BIND
if err := syscall.Mount(m.Source, dest, m.Device,uintptr(syscall.MS_BIND),data); err != nil {
Instead of changing or modifying m.Flags, add the MS_BIND option in go code..

or modify container.json to include option bind..

@cyphar
Copy link
Member

cyphar commented Jun 30, 2015

@InformatiQ On *nix systems, you need to specify mount -o bind /src /mnt. The -o maps to the option field in the OCF format. There is no such filesystem type as bind. In fact, the type field is ignored in this case and if you make it empty it still would work. So really, it would be surprising if specifying the type of mount as bind would work -- since that's now how mounting works.

@rajasec Please don't post large swathes of code in comments. Please either reference the code lines or just make a PR for review.

@InformatiQ
Copy link
Author

that works fine for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants