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) authorize an rsa ssh key.blockOnPort(int port, int seconds) When the node is started, wait until the following port is activeblockUntilRunning(boolean blockUntilRunning) Noteclone()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) Opens the set of ports to public access.installPrivateKey(String privateKey) replaces the rsa ssh key used at login.networkMode(String networkMode) Sets the networking mode for the container.Assigns the created nodes to these networksspecifies names to be used for the created nodes.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) This script will be executed as the root user upon system startup.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
When the node is started, wait until the following port is active- Overrides:
blockOnPortin classTemplateOptions
-
inboundPorts
Opens the set of ports to public access.- Overrides:
inboundPortsin classTemplateOptions
-
authorizePublicKey
authorize an rsa ssh key.- Overrides:
authorizePublicKeyin classTemplateOptions
-
installPrivateKey
replaces the rsa ssh key used at login.- Overrides:
installPrivateKeyin classTemplateOptions
-
blockUntilRunning
Note
As of version 1.1.0, this option is incompatible withTemplateOptions.runScript(Statement)andRunScriptOptions.blockOnComplete(boolean), as all current implementations utilize ssh in order to execute scripts.- Overrides:
blockUntilRunningin classTemplateOptions- Parameters:
blockUntilRunning- (default true) whether to block until the nodes in this template are instateinvalid reference
Status#RUNNING
-
dontAuthorizePublicKey
- Overrides:
dontAuthorizePublicKeyin classTemplateOptions
-
nameTask
- Overrides:
nameTaskin classTemplateOptions- Returns:
- What to call the task relating to this script; default
jclouds-script-timestampwhere timestamp is millis since epoch
-
runAsRoot
- Overrides:
runAsRootin classTemplateOptions
-
runScript
This script will be executed as the root user upon system startup. This script gets a prologue, so no #!/bin/bash required, path set up, etc- 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- Parameters:
userMetadata- user-defined metadata to assign to this server
-
userMetadata
- Overrides:
userMetadatain classTemplateOptions- Parameters:
key- key to place into the metadata mapvalue- value to associate with that key
-
nodeNames
specifies names to be used for the created nodes. Note that this does not guarantee uniqueness - if there are already existing nodes with a name specified here, there will still be a new node created with the same name. Also, if more nodes are to be created than there are names, subsequent names will use the default naming strategy for that cloud.- Overrides:
nodeNamesin classTemplateOptions
-
networks
Assigns the created nodes to these networks- Overrides:
networksin classTemplateOptions
-