mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-01-24 15:42:58 -05:00
provider/docker: #5298 Add support for docker run --user option
This commit is contained in:
parent
91cfbf9b4e
commit
5cdb31fec1
3 changed files with 16 additions and 0 deletions
|
|
@ -80,6 +80,13 @@ func resourceDockerContainer() *schema.Resource {
|
|||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
|
||||
"user": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
},
|
||||
|
||||
"dns": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
|||
createOpts.Config.Entrypoint = stringListToStringSlice(v.([]interface{}))
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("user"); ok {
|
||||
createOpts.Config.User = v.(string)
|
||||
}
|
||||
|
||||
exposedPorts := map[dc.Port]struct{}{}
|
||||
portBindings := map[dc.Port][]dc.PortBinding{}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ func TestAccDockerContainer_customized(t *testing.T) {
|
|||
return fmt.Errorf("Container wrong entrypoint: %s", c.Config.Entrypoint)
|
||||
}
|
||||
|
||||
if c.Config.User != "root:root" {
|
||||
return fmt.Errorf("Container wrong user: %s", c.Config.User)
|
||||
}
|
||||
|
||||
if c.HostConfig.RestartPolicy.Name == "on-failure" {
|
||||
if c.HostConfig.RestartPolicy.MaximumRetryCount != 5 {
|
||||
return fmt.Errorf("Container has wrong restart policy max retry count: %d", c.HostConfig.RestartPolicy.MaximumRetryCount)
|
||||
|
|
@ -217,6 +221,7 @@ resource "docker_container" "foo" {
|
|||
name = "tf-test"
|
||||
image = "${docker_image.foo.latest}"
|
||||
entrypoint = ["/bin/bash", "-c", "ping localhost"]
|
||||
user = "root:root"
|
||||
restart = "on-failure"
|
||||
max_retry_count = 5
|
||||
memory = 512
|
||||
|
|
|
|||
Loading…
Reference in a new issue