feat: implement mac_address for networks_advanced (#794)

This commit is contained in:
Martin 2025-09-26 13:14:14 +02:00 committed by GitHub
parent e2c8d0b73a
commit 9a17ba0670
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View file

@ -232,6 +232,7 @@ Optional:
- `aliases` (Set of String) The network aliases of the container in the specific network.
- `ipv4_address` (String) The IPV4 address of the container in the specific network.
- `ipv6_address` (String) The IPV6 address of the container in the specific network.
- `mac_address` (String) The MAC address of the container in the specific network.
<a id="nestedblock--ports"></a>

View file

@ -778,6 +778,12 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
},
"mac_address": {
Type: schema.TypeString,
Description: "The MAC address of the container in the specific network.",
Optional: true,
ForceNew: true,
},
},
},
},

View file

@ -460,6 +460,10 @@ func resourceDockerContainerCreate(ctx context.Context, d *schema.ResourceData,
}
endpointConfig.IPAMConfig = endpointIPAMConfig
if v, ok := rawNetwork.(map[string]interface{})["mac_address"]; ok {
endpointConfig.MacAddress = v.(string)
}
if err := client.NetworkConnect(ctx, networkID, retContainer.ID, endpointConfig); err != nil {
return diag.Errorf("Unable to connect to network '%s': %s", networkID, err)
}