public class DockerTemplateOptions extends TemplateOptions implements Cloneable
createNodes
operation on the docker provider.
DockerTemplateOptions.Builder.*
and invoke one of
the static creation methods, followed by an instance mutator if needed.
import static org.jclouds.docker.compute.options.DockerTemplateOptions.Builder.*;
ComputeService api = // get connection
templateBuilder.options(inboundPorts(22, 80, 8080, 443));
Set<? extends NodeMetadata> set = api.createNodesInGroup(tag, 2, templateBuilder.build());
In addition to basic configuration through its methods, this class also
provides possibility to work directly with Docker API configuration object (
Config.Builder
). When the
configBuilder(org.jclouds.docker.domain.Config.Builder)
is used to
configure not-null
configBuilder, then this configuration object
takes precedence over the other configuration in this class (i.e. the other
config entries are not used)
Note: The image
property in the provided Config.Builder
is rewritten by a placeholder value.
The real value is configured by ComputeServiceAdapter.
import static org.jclouds.docker.compute.options.DockerTemplateOptions.Builder.*;
ComputeService api = // get connection
DockerTemplateOptions options = DockerTemplateOptions.Builder
.configBuilder(
Config.builder().env(ImmutableList.<String> of("SSH_PORT=8822"))
.hostConfig(HostConfig.builder().networkMode("host").build()));
templateBuilder.options(options);
Set<? extends NodeMetadata> set = api.createNodesInGroup("sample-group", 1, templateBuilder.build());
Modifier and Type | Class and Description |
---|---|
static class |
DockerTemplateOptions.Builder |
TemplateOptions.ImmutableTemplateOptions
RunScriptOptions.ImmutableRunScriptOptions
Modifier and Type | Field and Description |
---|---|
protected Config.Builder |
configBuilder |
protected Integer |
cpuShares |
protected List<String> |
dns |
protected List<String> |
env |
protected Map<String,String> |
extraHosts |
protected String |
hostname |
protected Integer |
memory |
protected String |
networkMode |
protected boolean |
openStdin |
protected Map<Integer,Integer> |
portBindings |
protected boolean |
privileged |
protected Map<String,String> |
volumes |
protected List<String> |
volumesFrom |
blockUntilRunning, inboundPorts, networks, nodeNames, NONE, privateKey, publicKey, script, securityGroups, tags, userMetadata
authenticateSudo, blockOnComplete, loginPassword, loginPrivateKey, loginUser, port, runAsRoot, seconds, taskName, wrapInInitScript
Constructor and Description |
---|
DockerTemplateOptions() |
as, blockOnComplete, getGroups, getInboundPorts, getNetworks, getNodeNames, getPrivateKey, getPublicKey, getRunScript, getTags, getUserMetadata, networks, runScript, securityGroups, securityGroups, shouldBlockUntilRunning, string, tags, wrapInInitScript
copyTo, getLoginPassword, getLoginPrivateKey, getLoginUser, getPort, getSeconds, getTaskName, hasLoginPassword, hasLoginPasswordOption, hasLoginPrivateKey, hasLoginPrivateKeyOption, overrideLoginPassword, overrideLoginPrivateKey, shouldAuthenticateSudo, shouldBlockOnComplete, shouldRunAsRoot, shouldWrapInInitScript
protected boolean privileged
protected boolean openStdin
protected Config.Builder configBuilder
public DockerTemplateOptions clone()
clone
in class TemplateOptions
public void copyTo(TemplateOptions to)
copyTo
in class TemplateOptions
public boolean equals(Object o)
equals
in class TemplateOptions
public int hashCode()
hashCode
in class TemplateOptions
public String toString()
toString
in class RunScriptOptions
public DockerTemplateOptions volumes(Map<String,String> volumes)
public DockerTemplateOptions dns(Iterable<String> dns)
public DockerTemplateOptions dns(String... dns)
public DockerTemplateOptions hostname(@Nullable String hostname)
public DockerTemplateOptions memory(@Nullable Integer memory)
public DockerTemplateOptions entrypoint(Iterable<String> entrypoint)
public DockerTemplateOptions entrypoint(String... entrypoint)
public DockerTemplateOptions commands(Iterable<String> commands)
public DockerTemplateOptions commands(String... commands)
public DockerTemplateOptions cpuShares(@Nullable Integer cpuShares)
public DockerTemplateOptions env(Iterable<String> env)
public DockerTemplateOptions env(String... env)
public DockerTemplateOptions portBindings(Map<Integer,Integer> portBindings)
The Map
keys are host ports number, and the value for an entry is the
container port number. This is the same order as the arguments for the
--publish
command-line option to docker run
which is
hostPort:containerPort
.
portBindings
- the map of host to container port bindingspublic DockerTemplateOptions networkMode(@Nullable String networkMode)
Supported values are: bridge
, none
, host
,
networkname
, networkid
or container:[name|id]
networkMode
- public DockerTemplateOptions extraHosts(Map<String,String> extraHosts)
The Map
keys are host names, and the value is an IP address that
can be accessed by the container. This is the same order as the arguments for the
--add-host
command-line option to docker run
.
extraHosts
- the map of host names to IP addressespublic DockerTemplateOptions volumesFrom(Iterable<String> volumesFrom)
volumesFrom
- the list of container namespublic DockerTemplateOptions privileged(boolean privileged)
privileged
- Whether the container should run in privileged mode or notpublic DockerTemplateOptions openStdin(boolean openStdin)
STDIN
open when running interactive workloads in the container.openStdin
- Whether the container should keep STDIN openpublic DockerTemplateOptions configBuilder(Config.Builder configBuilder)
configBuilder
- Config.Builder instance. This instance can be changed in this
method!public String getHostname()
public Integer getMemory()
public Integer getCpuShares()
public String getNetworkMode()
public boolean getPrivileged()
public boolean getOpenStdin()
public Config.Builder getConfigBuilder()
public DockerTemplateOptions blockOnPort(int port, int seconds)
blockOnPort
in class TemplateOptions
public DockerTemplateOptions inboundPorts(int... ports)
inboundPorts
in class TemplateOptions
public DockerTemplateOptions authorizePublicKey(String publicKey)
authorizePublicKey
in class TemplateOptions
public DockerTemplateOptions installPrivateKey(String privateKey)
installPrivateKey
in class TemplateOptions
public DockerTemplateOptions blockUntilRunning(boolean blockUntilRunning)
TemplateOptions.runScript(Statement)
and
RunScriptOptions.blockOnComplete(boolean)
, as all current
implementations utilize ssh in order to execute scripts.blockUntilRunning
in class TemplateOptions
blockUntilRunning
- (default true) whether to block until the nodes in this template
are in Status#RUNNING
statepublic DockerTemplateOptions dontAuthorizePublicKey()
dontAuthorizePublicKey
in class TemplateOptions
public DockerTemplateOptions nameTask(String name)
nameTask
in class TemplateOptions
jclouds-script-timestamp
where timestamp is millis since
epochpublic DockerTemplateOptions runAsRoot(boolean runAsRoot)
runAsRoot
in class TemplateOptions
public DockerTemplateOptions runScript(Statement script)
runScript
in class TemplateOptions
public DockerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials)
overrideLoginCredentials
in class TemplateOptions
public DockerTemplateOptions overrideLoginPassword(String password)
overrideLoginPassword
in class TemplateOptions
public DockerTemplateOptions overrideLoginPrivateKey(String privateKey)
overrideLoginPrivateKey
in class TemplateOptions
public DockerTemplateOptions overrideLoginUser(String loginUser)
overrideLoginUser
in class TemplateOptions
public DockerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo)
overrideAuthenticateSudo
in class TemplateOptions
public DockerTemplateOptions userMetadata(Map<String,String> userMetadata)
userMetadata
in class TemplateOptions
userMetadata
- user-defined metadata to assign to this serverpublic DockerTemplateOptions userMetadata(String key, String value)
userMetadata
in class TemplateOptions
key
- key to place into the metadata mapvalue
- value to associate with that keypublic DockerTemplateOptions nodeNames(Iterable<String> nodeNames)
nodeNames
in class TemplateOptions
public DockerTemplateOptions networks(Iterable<String> networks)
networks
in class TemplateOptions
Copyright © 2009-2016 The Apache Software Foundation. All Rights Reserved.