mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Allow user to choose the IP address for the container
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
19b063e740
commit
2bb3fc1bc5
26 changed files with 412 additions and 157 deletions
|
@ -261,6 +261,14 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network) ([]
|
|||
createOptions = append(createOptions, libnetwork.CreateOptionAnonymous())
|
||||
}
|
||||
|
||||
if epConfig, ok := container.NetworkSettings.Networks[n.Name()]; ok {
|
||||
ipam := epConfig.IPAMConfig
|
||||
if ipam != nil && (ipam.IPv4Address != "" || ipam.IPv6Address != "") {
|
||||
createOptions = append(createOptions,
|
||||
libnetwork.CreateOptionIpam(net.ParseIP(ipam.IPv4Address), net.ParseIP(ipam.IPv6Address), nil))
|
||||
}
|
||||
}
|
||||
|
||||
// Other configs are applicable only for the endpoint in the network
|
||||
// to which container was connected to on docker run.
|
||||
if n.Name() != container.HostConfig.NetworkMode.NetworkName() &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue