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

config.json failed(permission denied) "chdir to cwd (\"/\") set" #1712

Open
Taeung opened this issue Feb 6, 2018 · 2 comments
Open

config.json failed(permission denied) "chdir to cwd (\"/\") set" #1712

Taeung opened this issue Feb 6, 2018 · 2 comments

Comments

@Taeung
Copy link
Contributor

Taeung commented Feb 6, 2018

Hi,

This problem occurs when running runc run test.

I wonder the cause of this problem and how to fix it,
however, I didn't yet find out it..

Preparation:

I got rootfs/ from https://alpinelinux.org/downloads/

$ curl -O http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/x86_64/alpine-minirootfs-3.7.0-x86_64.tar.gz

$ mkdir rootfs && tar xf alpine-minirootfs-3.7.0-x86_64.tar.gz -C rootfs

$ runc spec && ls
config.json  rootfs

Problem situation:

$ sudo runc run test
container_linux.go:348: starting container process caused "chdir to cwd (\"/\") set in config.json failed: permission denied"

This problem seems to be related with:

  1. libcontainer/init_linux.go:154~157
119 func finalizeNamespace(config *initConfig) error {
...
154         if config.Cwd != "" {
155                 if err := unix.Chdir(config.Cwd); err != nil {
156                         return fmt.Errorf("chdir to cwd (%q) set in config.json failed: %v", config.Cwd, err)
  1. libcontainer/container_linux.go:348
338 func (c *linuxContainer) start(process *Process, isInit bool) error {
339         parent, err := c.newParentProcess(process, isInit)
340         if err != nil {
341                 return newSystemErrorWithCause(err, "creating new parent process")
342         }
343         if err := parent.start(); err != nil {
344                 // terminate the process to ensure that it properly is reaped.                                    
345                 if err := ignoreTerminateErrors(parent.terminate()); err != nil {
346                         logrus.Warn(err)
347                 }
348                 return newSystemErrorWithCause(err, "starting container process")
349         }

But I don't know the specific reason very well..
This problem came from alpinelinux rootfs/ ?
(cf. busybox example is OK)

I'd appreciate it, if you help this.

@ldd91
Copy link

ldd91 commented Apr 1, 2019

I met the same problem

@EricJeffrey
Copy link

Apparently, #2086 has shown the reason:
Cwd is not owned by root.
So chown will do

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

3 participants