Skip to content

Commit

Permalink
add support privilege to container
Browse files Browse the repository at this point in the history
Signed-off-by: Xian Chaobo <[email protected]>
  • Loading branch information
jimmyxian committed Jul 6, 2016
1 parent 4ccbd4d commit c68ad23
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 84 deletions.
5 changes: 3 additions & 2 deletions agent/exec/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ func getMountMask(m *api.Mount) string {

func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
return &enginecontainer.HostConfig{
Resources: c.resources(),
Binds: c.binds(),
Resources: c.resources(),
Binds: c.binds(),
Privileged: c.spec().Privileged,
}
}

Expand Down
204 changes: 122 additions & 82 deletions api/specs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/specs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ message ContainerSpec {

// PullOptions parameterize the behavior of image pulls.
PullOptions pull_options = 10;

// Privileged give extended privileges to the container.
bool Privileged = 11;
}

// EndpointSpec defines the properties that can be configured to
Expand Down
8 changes: 8 additions & 0 deletions cmd/swarmctl/service/flagparser/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,13 @@ func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
spec.Task.GetContainer().Env = env
}

if flags.Changed("privileged") {
privileged, err := flags.GetBool("privileged")
if err != nil {
return err
}
spec.Task.GetContainer().Privileged = privileged
}

return nil
}
1 change: 1 addition & 0 deletions cmd/swarmctl/service/flagparser/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func AddServiceFlags(flags *pflag.FlagSet) {
flags.StringSlice("command", nil, "override entrypoint")
flags.StringSlice("args", nil, "container args")
flags.StringSlice("env", nil, "container env")
flags.BoolP("privileged", "", false, "give extended privileges to container (default false)")

flags.StringSlice("ports", nil, "ports")
flags.String("network", "", "network name")
Expand Down

0 comments on commit c68ad23

Please sign in to comment.