com.github.dockerjava.api.command.CreateNetworkCmd Java Examples

The following examples show how to use com.github.dockerjava.api.command.CreateNetworkCmd. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Network.java    From testcontainers-java with MIT License 6 votes vote down vote up
private String create() {
    CreateNetworkCmd createNetworkCmd = DockerClientFactory.instance().client().createNetworkCmd();

    createNetworkCmd.withName(name);
    createNetworkCmd.withCheckDuplicate(true);

    if (enableIpv6 != null) {
        createNetworkCmd.withEnableIpv6(enableIpv6);
    }

    if (driver != null) {
        createNetworkCmd.withDriver(driver);
    }

    for (Consumer<CreateNetworkCmd> consumer : createNetworkCmdModifiers) {
        consumer.accept(createNetworkCmd);
    }

    Map<String, String> labels = createNetworkCmd.getLabels();
    labels = new HashMap<>(labels != null ? labels : Collections.emptyMap());
    labels.putAll(DockerClientFactory.DEFAULT_LABELS);
    createNetworkCmd.withLabels(labels);

    return createNetworkCmd.exec().getId();
}
 
Example #2
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public CreateNetworkCmd withLabels(Map<String, String> labels) {
    checkNotNull(labels, "labels was not specified");
    this.labels = labels;
    return this;
}
 
Example #3
Source File: CreateNetworkCmdExec.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Override
protected CreateNetworkResponse execute(CreateNetworkCmd command) {
    WebTarget webResource = getBaseResource().path("/networks/create");

    LOGGER.trace("POST: {}", webResource);
    return webResource.request().accept(MediaType.APPLICATION_JSON)
            .post(command, new TypeReference<CreateNetworkResponse>() {
            });
}
 
Example #4
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withDriver(String driver) {
    this.driver = driver;
    return this;
}
 
Example #5
Source File: DelegatingDockerClient.java    From docker-plugin with MIT License 4 votes vote down vote up
@Override
public CreateNetworkCmd createNetworkCmd() {
    return getDelegate().createNetworkCmd();
}
 
Example #6
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public CreateNetworkCmd withAttachable(Boolean attachable) {
    this.attachable = attachable;
    return this;
}
 
Example #7
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withEnableIpv6(boolean enableIpv6) {
    this.enableIpv6 = enableIpv6;
    return this;
}
 
Example #8
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withInternal(boolean internal) {
    this.internal = internal;
    return this;
}
 
Example #9
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withCheckDuplicate(boolean checkDuplicate) {
    this.checkDuplicate = checkDuplicate;
    return this;
}
 
Example #10
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withOptions(Map<String, String> options) {
    this.options = options;
    return this;
}
 
Example #11
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withIpam(Ipam ipam) {
    this.ipam = ipam;
    return this;
}
 
Example #12
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd withName(String name) {
    this.name = name;
    return this;
}
 
Example #13
Source File: CreateNetworkCmdImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
public CreateNetworkCmdImpl(DockerCmdSyncExec<CreateNetworkCmd, CreateNetworkResponse> execution) {
    super(execution);
}
 
Example #14
Source File: AbstractDockerCmdExecFactory.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd.Exec createCreateNetworkCmdExec() {
    return new CreateNetworkCmdExec(getBaseResource(), getDockerClientConfig());
}
 
Example #15
Source File: DockerClientImpl.java    From docker-java with Apache License 2.0 4 votes vote down vote up
@Override
public CreateNetworkCmd createNetworkCmd() {
    return new CreateNetworkCmdImpl(getDockerCmdExecFactory().createCreateNetworkCmdExec());
}
 
Example #16
Source File: DockerRule.java    From docker-java with Apache License 2.0 4 votes vote down vote up
private CreateNetworkCmdDelegate(CreateNetworkCmd delegate) {
    this.delegate = delegate;
}
 
Example #17
Source File: DockerClient.java    From docker-java with Apache License 2.0 votes vote down vote up
CreateNetworkCmd createNetworkCmd();