privilege enabled docker container (#3475)

Issue #2724
This commit is contained in:
Hao 2016-04-29 22:12:20 -04:00 committed by Chris Bednarski
parent 700966fc27
commit 5139b853fa
4 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,7 @@ type Config struct {
Pull bool
RunCommand []string `mapstructure:"run_command"`
Volumes map[string]string
Privileged bool `mapstructure:"privileged"`
// This is used to login to dockerhub to pull a private base container. For
// pushing to dockerhub, see the docker post-processors

View File

@ -64,6 +64,7 @@ type ContainerConfig struct {
Image string
RunCommand []string
Volumes map[string]string
Privileged bool
}
// This is the template that is used for the RunCommand in the ContainerConfig.

View File

@ -210,6 +210,9 @@ func (d *DockerDriver) StartContainer(config *ContainerConfig) (string, error) {
// Args that we're going to pass to Docker
args := []string{"run"}
if config.Privileged {
args = append(args, "--privileged")
}
for host, guest := range config.Volumes {
args = append(args, "-v", fmt.Sprintf("%s:%s", host, guest))
}

View File

@ -20,6 +20,7 @@ func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction {
Image: config.Image,
RunCommand: config.RunCommand,
Volumes: make(map[string]string),
Privileged: config.Privileged,
}
for host, container := range config.Volumes {