mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Add the networks entry
This commit is contained in:
parent
f09280891c
commit
6e36095644
@ -238,6 +238,12 @@ func resourceDockerContainer() *schema.Resource {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"networks": &schema.Schema{
|
||||||
|
Type: schema.TypeSet,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,14 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
|||||||
|
|
||||||
d.SetId(retContainer.ID)
|
d.SetId(retContainer.ID)
|
||||||
|
|
||||||
|
if v, ok := d.GetOk("networks"); ok {
|
||||||
|
connectionOpts := &dc.NetworkConnectionOptions{Container: retContainer.ID}
|
||||||
|
|
||||||
|
for _, network := range v.(*schema.Set).List() {
|
||||||
|
client.ConnectNetwork(network.(string), connectionOpts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -68,6 +68,7 @@ The following arguments are supported:
|
|||||||
Defaults to "json-file".
|
Defaults to "json-file".
|
||||||
* `log_opts` - (Optional) Key/value pairs to use as options for the logging
|
* `log_opts` - (Optional) Key/value pairs to use as options for the logging
|
||||||
driver.
|
driver.
|
||||||
|
* `networks` - (Optional, set of strings) Id of the networks in which the container is.
|
||||||
|
|
||||||
<a id="ports"></a>
|
<a id="ports"></a>
|
||||||
## Ports
|
## Ports
|
||||||
|
Loading…
Reference in New Issue
Block a user