@Override
    public CreateContainerResponse exec() throws NotFoundException, ConflictException {
        //code flow taken from https://github.com/docker/docker/blob/master/runconfig/opts/parse.go
        ContainerNetwork containerNetwork = null;

        if (ipv4Address != null || ipv6Address != null) {
            containerNetwork = new ContainerNetwork()
                    .withIpamConfig(new ContainerNetwork.Ipam()
                            .withIpv4Address(ipv4Address)
                            .withIpv6Address(ipv6Address)
                    );

        }

        if (hostConfig.isUserDefinedNetwork() && hostConfig.getLinks().length > 0) {
            if (containerNetwork == null) {
                containerNetwork = new ContainerNetwork();
            }

            containerNetwork.withLinks(hostConfig.getLinks());
        }

        if (aliases != null) {
            if (containerNetwork == null) {
                containerNetwork = new ContainerNetwork();
            }

            containerNetwork.withAliases(aliases);
        }

        if (containerNetwork != null) {
            networkingConfig = new NetworkingConfig()
                    .withEndpointsConfig(singletonMap(hostConfig.getNetworkMode(), containerNetwork));
        }

        return super.exec();
    }
@ Override public CreateContainerResponse exec ( ) throws NotFoundException , ConflictException { ContainerNetwork containerNetwork = null ; if ( ipv4Address != null || ipv6Address != null ) { containerNetwork = new ContainerNetwork ( ) . withIpamConfig ( new ContainerNetwork . Ipam ( ) . withIpv4Address ( ipv4Address ) . withIpv6Address ( ipv6Address ) ) ; } if ( hostConfig . isUserDefinedNetwork ( ) && hostConfig . getLinks ( ) . length > 0 ) { if ( containerNetwork == null ) { containerNetwork = new ContainerNetwork ( ) ; } containerNetwork . withLinks ( hostConfig . getLinks ( ) ) ; } if ( aliases != null ) { if ( containerNetwork == null ) { containerNetwork = new ContainerNetwork ( ) ; } containerNetwork . withAliases ( aliases ) ; } if ( containerNetwork != null ) { networkingConfig = new NetworkingConfig ( ) . withEndpointsConfig ( singletonMap ( hostConfig . getNetworkMode ( ) , containerNetwork ) ) ; } return super . exec ( ) ; }
@throws NotFoundException No such container
@throws ConflictException Named container already exists