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

fork/exec /bin/sh: operation not permitted exit status 1 #78

Open
chengyayu opened this issue Oct 16, 2020 · 3 comments
Open

fork/exec /bin/sh: operation not permitted exit status 1 #78

chengyayu opened this issue Oct 16, 2020 · 3 comments

Comments

@chengyayu
Copy link

chengyayu commented Oct 16, 2020

Q1:请问项目中代码的开发环境是什么?

我使用 mac 开发,按照示例中的代码编写时,发现有些API是不兼容的。所以我采用了 remote-dev 的方式开启了一个容器,在容器中开发,这样 API 的操作系统不兼容的问题解决了。

我容器开发环境如下:go1.15.3 linux/amd64

Q2:为什么会出现 fork/exec /bin/sh: operation not permitted exit status 1?

func main() {
	cmd := exec.Command("sh")
	cmd.SysProcAttr = &syscall.SysProcAttr{Cloneflags: syscall.CLONE_NEWUTS}
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	if err := cmd.Run(); err != nil {
		log.Fatal(err)
	}
}

执行

go run main.go

报错:
fork/exec /bin/sh: operation not permitted exit status 1

@HhTtLllL
Copy link

HhTtLllL commented Dec 9, 2020

运行的容器没有root权限,加上 --privileged 参数,才能使容器拥有root权限。

@xChen16
Copy link

xChen16 commented Aug 12, 2021

运行的容器没有root权限,加上--特权参数,才能使容器拥有root权限。
他这个不是容器啊,哪来的--privileged参数啊,只是没有权限获取系统的CLONE_NEWUTS,sudo就可以了

@ForeverSRC
Copy link

ForeverSRC commented Dec 13, 2021

如果要在一个ubuntu的docker容器中运行的mydocker,需要--privileged

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