include hostconfig when creating docker_container
This commit is contained in:
parent
1f739d31da
commit
b5ae355a99
|
@ -86,16 +86,6 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
||||||
createOpts.Config.Labels = mapTypeMapValsToString(v.(map[string]interface{}))
|
createOpts.Config.Labels = mapTypeMapValsToString(v.(map[string]interface{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
var retContainer *dc.Container
|
|
||||||
if retContainer, err = client.CreateContainer(createOpts); err != nil {
|
|
||||||
return fmt.Errorf("Unable to create container: %s", err)
|
|
||||||
}
|
|
||||||
if retContainer == nil {
|
|
||||||
return fmt.Errorf("Returned container is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
d.SetId(retContainer.ID)
|
|
||||||
|
|
||||||
hostConfig := &dc.HostConfig{
|
hostConfig := &dc.HostConfig{
|
||||||
Privileged: d.Get("privileged").(bool),
|
Privileged: d.Get("privileged").(bool),
|
||||||
PublishAllPorts: d.Get("publish_all_ports").(bool),
|
PublishAllPorts: d.Get("publish_all_ports").(bool),
|
||||||
|
@ -155,6 +145,18 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
||||||
hostConfig.LogConfig.Config = mapTypeMapValsToString(v.(map[string]interface{}))
|
hostConfig.LogConfig.Config = mapTypeMapValsToString(v.(map[string]interface{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createOpts.HostConfig = hostConfig
|
||||||
|
|
||||||
|
var retContainer *dc.Container
|
||||||
|
if retContainer, err = client.CreateContainer(createOpts); err != nil {
|
||||||
|
return fmt.Errorf("Unable to create container: %s", err)
|
||||||
|
}
|
||||||
|
if retContainer == nil {
|
||||||
|
return fmt.Errorf("Returned container is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
d.SetId(retContainer.ID)
|
||||||
|
|
||||||
creationTime = time.Now()
|
creationTime = time.Now()
|
||||||
if err := client.StartContainer(retContainer.ID, hostConfig); err != nil {
|
if err := client.StartContainer(retContainer.ID, hostConfig); err != nil {
|
||||||
return fmt.Errorf("Unable to start container: %s", err)
|
return fmt.Errorf("Unable to start container: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue