Class DockerTemplateOptions
- All Implemented Interfaces:
Cloneable
createNodes operation on the docker provider.
Usage
The recommended way to instantiate a DockerTemplateOptions object is to statically importDockerTemplateOptions.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());
Advanced Usage
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());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.jclouds.compute.options.TemplateOptions
TemplateOptions.ImmutableTemplateOptionsNested classes/interfaces inherited from class org.jclouds.compute.options.RunScriptOptions
RunScriptOptions.ImmutableRunScriptOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Config.Builderprotected Integerprotected Stringprotected Integerprotected Stringprotected booleanprotected booleanFields inherited from class org.jclouds.compute.options.TemplateOptions
blockUntilRunning, inboundPorts, networks, nodeNames, NONE, privateKey, publicKey, script, securityGroups, tags, userMetadataFields inherited from class org.jclouds.compute.options.RunScriptOptions
authenticateSudo, blockOnComplete, loginPassword, loginPrivateKey, loginUser, port, runAsRoot, seconds, taskName, wrapInInitScript -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthorizePublicKey(String publicKey) blockOnPort(int port, int seconds) blockUntilRunning(boolean blockUntilRunning) clone()configBuilder(Config.Builder configBuilder) This method sets Config.Builder configuration object, which can be used as a replacement for all the other settings from this class.voidentrypoint(Iterable<String> entrypoint) entrypoint(String... entrypoint) booleanextraHosts(Map<String, String> extraHosts) Set extra hosts file entries for a container.getDns()getEnv()booleanbooleaninthashCode()inboundPorts(int... ports) installPrivateKey(String privateKey) networkMode(String networkMode) Sets the networking mode for the container.openStdin(boolean openStdin) KeepSTDINopen when running interactive workloads in the container.overrideAuthenticateSudo(boolean authenticateSudo) overrideLoginCredentials(LoginCredentials overridingCredentials) overrideLoginPassword(String password) overrideLoginPrivateKey(String privateKey) overrideLoginUser(String loginUser) portBindings(Map<Integer, Integer> portBindings) Set port bindings between the Docker host and a container.privileged(boolean privileged) By default, Docker containers are unprivileged and cannot execute privileged operations or access certain host devices.runAsRoot(boolean runAsRoot) runScript(org.jclouds.scriptbuilder.domain.Statement script) toString()userMetadata(String key, String value) userMetadata(Map<String, String> userMetadata) volumesFrom(Iterable<String> volumesFrom) Set list of containers to mount volumes from onto this container.Methods inherited from class org.jclouds.compute.options.TemplateOptions
as, blockOnComplete, getGroups, getInboundPorts, getNetworks, getNodeNames, getPrivateKey, getPublicKey, getRunScript, getTags, getUserMetadata, networks, runScript, securityGroups, securityGroups, shouldBlockUntilRunning, string, tags, wrapInInitScriptMethods inherited from class org.jclouds.compute.options.RunScriptOptions
copyTo, getLoginPassword, getLoginPrivateKey, getLoginUser, getPort, getSeconds, getTaskName, hasLoginPassword, hasLoginPasswordOption, hasLoginPrivateKey, hasLoginPrivateKeyOption, overrideLoginPassword, overrideLoginPrivateKey, shouldAuthenticateSudo, shouldBlockOnComplete, shouldRunAsRoot, shouldWrapInInitScript
-
Field Details
-
dns
-
hostname
-
memory
-
volumes
-
env
-
portBindings
-
networkMode
-
extraHosts
-
volumesFrom
-
privileged
protected boolean privileged -
openStdin
protected boolean openStdin -
configBuilder
-
-
Constructor Details
-
DockerTemplateOptions
public DockerTemplateOptions()
-
-
Method Details
-
clone
- Overrides:
clonein classTemplateOptions
-
copyTo
- Overrides:
copyToin classTemplateOptions
-
equals
- Overrides:
equalsin classTemplateOptions
-
hashCode
public int hashCode()- Overrides:
hashCodein classTemplateOptions
-
toString
- Overrides:
toStringin classRunScriptOptions
-
volumes
-
dns
-
dns
-
hostname
-
memory
-
entrypoint
-
entrypoint
-
commands
-
commands
-
env
-
env
-
portBindings
Set port bindings between the Docker host and a container.The
Mapkeys 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--publishcommand-line option todocker runwhich ishostPort:containerPort.- Parameters:
portBindings- the map of host to container port bindings
-
networkMode
Sets the networking mode for the container.Supported values are:
bridge,none,host,networkname,networkidorcontainer:[name|id]- Parameters:
networkMode-- Returns:
- this instance
-
extraHosts
Set extra hosts file entries for a container.The
Mapkeys 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-hostcommand-line option todocker run.- Parameters:
extraHosts- the map of host names to IP addresses
-
volumesFrom
Set list of containers to mount volumes from onto this container.- Parameters:
volumesFrom- the list of container names
-
privileged
By default, Docker containers are unprivileged and cannot execute privileged operations or access certain host devices.- Parameters:
privileged- Whether the container should run in privileged mode or not- Returns:
- this instance
-
openStdin
KeepSTDINopen when running interactive workloads in the container.- Parameters:
openStdin- Whether the container should keep STDIN open- Returns:
- this instance
-
configBuilder
This method sets Config.Builder configuration object, which can be used as a replacement for all the other settings from this class. Some values in the provided Config.Builder instance (the image name for instance) can be ignored or their value can be changed.- Parameters:
configBuilder- Config.Builder instance. This instance can be changed in this method!
-
getVolumes
-
getDns
-
getVolumesFrom
-
getHostname
-
getMemory
-
getEntrypoint
-
getCommands
-
getEnv
-
getPortBindings
-
getNetworkMode
-
getExtraHosts
-
getPrivileged
public boolean getPrivileged() -
getOpenStdin
public boolean getOpenStdin() -
getConfigBuilder
-
blockOnPort
- Overrides:
blockOnPortin classTemplateOptions
-
inboundPorts
- Overrides:
inboundPortsin classTemplateOptions
-
authorizePublicKey
- Overrides:
authorizePublicKeyin classTemplateOptions
-
installPrivateKey
- Overrides:
installPrivateKeyin classTemplateOptions
-
blockUntilRunning
- Overrides:
blockUntilRunningin classTemplateOptions
-
dontAuthorizePublicKey
- Overrides:
dontAuthorizePublicKeyin classTemplateOptions
-
nameTask
- Overrides:
nameTaskin classTemplateOptions
-
runAsRoot
- Overrides:
runAsRootin classTemplateOptions
-
runScript
- Overrides:
runScriptin classTemplateOptions
-
overrideLoginCredentials
- Overrides:
overrideLoginCredentialsin classTemplateOptions
-
overrideLoginPassword
- Overrides:
overrideLoginPasswordin classTemplateOptions
-
overrideLoginPrivateKey
- Overrides:
overrideLoginPrivateKeyin classTemplateOptions
-
overrideLoginUser
- Overrides:
overrideLoginUserin classTemplateOptions
-
overrideAuthenticateSudo
- Overrides:
overrideAuthenticateSudoin classTemplateOptions
-
userMetadata
- Overrides:
userMetadatain classTemplateOptions
-
userMetadata
- Overrides:
userMetadatain classTemplateOptions
-
nodeNames
- Overrides:
nodeNamesin classTemplateOptions
-
networks
- Overrides:
networksin classTemplateOptions
-