Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.

Commit 5c14f17

Browse files
aws-gibbsktchienhanlin
authored andcommitted
Add the CAP_CHOWN capability to support running rootless
1 parent a531f42 commit 5c14f17

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

ecs-init/docker/docker.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const (
7979
// For more information on setns, please read this manpage:
8080
// http://man7.org/linux/man-pages/man2/setns.2.html
8181
CapSysAdmin = "SYS_ADMIN"
82+
// CapChown to start agent with CAP_CHOWN capability
83+
// This is needed for the ECS Agent to invoke the chown call when
84+
// configuring the files for configuration or administration.
85+
// http://man7.org/linux/man-pages/man2/chown.2.html
86+
CapChown = "CAP_CHOWN"
8287
// DefaultCgroupMountpoint is the default mount point for the cgroup subsystem
8388
DefaultCgroupMountpoint = "/sys/fs/cgroup"
8489
// pluginSocketFilesDir specifies the location of UNIX domain socket files of

ecs-init/docker/docker_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func createHostConfig(binds []string) *godocker.HostConfig {
4949
// CapNetAdmin and CapSysAdmin are needed for running task in awsvpc network mode.
5050
// This network mode is (at least currently) not supported in external environment,
5151
// hence not adding them in that case.
52-
caps = []string{CapNetAdmin, CapSysAdmin}
52+
caps = []string{CapNetAdmin, CapSysAdmin, CapChown}
5353
}
5454

5555
hostConfig := &godocker.HostConfig{

ecs-init/docker/docker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func validateCommonCreateContainerOptions(opts godocker.CreateContainerOptions,
288288
t.Errorf("Expected network mode to be %s, got %s", networkMode, hostCfg.NetworkMode)
289289
}
290290

291-
if len(hostCfg.CapAdd) != 2 {
291+
if len(hostCfg.CapAdd) != 3 {
292292
t.Error("Mismatch detected in added host config capabilities")
293293
}
294294

0 commit comments

Comments
 (0)