Skip to content

Commit

Permalink
Updates rootless params and adds new Init: true requirement
Browse files Browse the repository at this point in the history
Init: true is needed for the first process spawning in a container

Signed-off-by: ncordon <[email protected]>
  • Loading branch information
ncordon committed Oct 27, 2019
1 parent 8b0945f commit 8ddd68f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 7 additions & 0 deletions runtime/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (s *ContainerSuite) TestContainer_Run() {
p := &Process{
Args: []string{"/bin/ls"},
Stdout: os.Stdout,
Init: true,
}

c, err := s.Runtime.Container("run", s.Image, p, nil)
Expand All @@ -67,6 +68,7 @@ func (s *ContainerSuite) TestContainer_StartStopStart() {
p := &Process{
Args: []string{"/bin/sleep", "5m"},
Stdout: os.Stdout,
Init: true,
}

c, err := s.Runtime.Container("1", s.Image, p, nil)
Expand All @@ -82,6 +84,7 @@ func (s *ContainerSuite) TestContainer_StartStopStart() {
p = &Process{
Args: []string{"/bin/sleep", "5m"},
Stdout: os.Stdout,
Init: true,
}

c, err = s.Runtime.Container("2", s.Image, p, nil)
Expand All @@ -103,6 +106,7 @@ func (s *ContainerSuite) TestContainer_StartWait() {
p := &Process{
Args: []string{"/bin/ls"},
Stdout: out,
Init: true,
}

c, err := s.Runtime.Container("wait", s.Image, p, nil)
Expand All @@ -125,6 +129,7 @@ func (s *ContainerSuite) TestContainer_StartWaitExit1() {
p := &Process{
Args: []string{"/bin/false"},
Stdout: out,
Init: true,
}

c, err := s.Runtime.Container("wait-exit", s.Image, p, nil)
Expand All @@ -147,6 +152,7 @@ func (s *ContainerSuite) TestContainer_StartFailure() {
p := &Process{
Args: []string{"/bin/non-existent"},
Stdout: out,
Init: true,
}

c, err := s.Runtime.Container("start-failure", s.Image, p, nil)
Expand All @@ -164,6 +170,7 @@ func (s *ContainerSuite) TestContainer_Env() {
p := &Process{
Args: []string{"/bin/env"},
Stdout: out,
Init: true,
}

c, err := s.Runtime.Container("env", s.Image, p, nil)
Expand Down
11 changes: 3 additions & 8 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *Runtime) Init() error {
var err error
r.f, err = libcontainer.New(
filepath.Join(r.Root, containersPath),
libcontainer.Cgroupfs,
libcontainer.RootlessCgroupfs,
)

return err
Expand Down Expand Up @@ -105,7 +105,8 @@ func ContainerConfigFactory(containerID string) *configs.Config {
defaultMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV

return &configs.Config{
Rootless: true,
RootlessEUID: true,
RootlessCgroups: true,
Namespaces: configs.Namespaces([]configs.Namespace{
{Type: configs.NEWNS},
{Type: configs.NEWUTS},
Expand Down Expand Up @@ -164,12 +165,6 @@ func ContainerConfigFactory(containerID string) *configs.Config {
Device: "mqueue",
Flags: defaultMountFlags,
},
//{
// Source: "sysfs",
// Destination: "/sys",
// Device: "sysfs",
// Flags: defaultMountFlags | syscall.MS_RDONLY,
//},
{
Source: "/etc/localtime",
Destination: "/etc/localtime",
Expand Down

0 comments on commit 8ddd68f

Please sign in to comment.