Class DockerRunCommand
- java.lang.Object
-
- org.apache.storm.container.docker.DockerCommand
-
- org.apache.storm.container.docker.DockerRunCommand
-
public class DockerRunCommand extends DockerCommand
Encapsulates the docker run command and its command line arguments.
-
-
Constructor Summary
Constructors Constructor Description DockerRunCommand(String containerName, String userInfo, String image)
The Construction function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DockerRunCommand
addAllReadOnlyMountLocations(List<String> paths)
Add all readonly locations.DockerRunCommand
addAllReadOnlyMountLocations(List<String> paths, boolean createSource)
Add all readonly locations.DockerRunCommand
addAllReadWriteMountLocations(List<String> paths)
Add all the rw bind mount locations.DockerRunCommand
addAllReadWriteMountLocations(List<String> paths, boolean createSource)
Add all the rw bind mount locations.DockerRunCommand
addCpuSetBindings(List<String> cores, String memoryNode)
DockerRunCommand
addDevice(String sourceDevice, String destinationDevice)
Set --device option.DockerRunCommand
addReadOnlyMountLocation(String sourcePath, String destinationPath)
Add readonly bind mout location.DockerRunCommand
addReadOnlyMountLocation(String sourcePath, String destinationPath, boolean createSource)
Add readonly bind mount location.DockerRunCommand
addReadWriteMountLocation(String sourcePath, String destinationPath)
DockerRunCommand
addReadWriteMountLocation(String sourcePath, String destinationPath, boolean createSource)
Add bind mount locations.DockerRunCommand
detachOnRun()
Add -d option.DockerRunCommand
disableDetach()
Disable detach.DockerRunCommand
enableDetach()
Enable detach.String
getCommandWithArguments()
Get the full command.DockerRunCommand
groupAdd(String[] groups)
Set --group-add option.DockerRunCommand
removeContainerOnExit()
Add --rm option.DockerRunCommand
setCapabilities(Set<String> capabilities)
Set capabilities of the container.DockerRunCommand
setCGroupParent(String parentPath)
Set --cgroup-parent option.DockerRunCommand
setCidFile(String cidFile)
Set the output container id file location.DockerRunCommand
setContainerWorkDir(String workdir)
Set --workdir option.DockerRunCommand
setCpus(double cpus)
Set the number of cpus to use.DockerRunCommand
setCpuShares(int cpuShares)
Set cpuShares.DockerRunCommand
setMemoryMb(int memoryMb)
Set the number of memory in MB to use.DockerRunCommand
setNetworkType(String type)
Set --net option.DockerRunCommand
setNoNewPrivileges()
Set no-new-privileges option.DockerRunCommand
setOverrideCommandWithArgs(List<String> overrideCommandWithArgs)
Set extra commands and args.DockerRunCommand
setPrivileged()
Set --privileged option to run a privileged container.DockerRunCommand
setReadonly()
Add --read-only option.DockerRunCommand
setSeccompProfile(String jsonPath)
Set --security-opt option.-
Methods inherited from class org.apache.storm.container.docker.DockerCommand
addCommandArguments, getCommandOption
-
-
-
-
Method Detail
-
removeContainerOnExit
public DockerRunCommand removeContainerOnExit()
Add --rm option.- Returns:
- the self
-
detachOnRun
public DockerRunCommand detachOnRun()
Add -d option.- Returns:
- the self
-
setContainerWorkDir
public DockerRunCommand setContainerWorkDir(String workdir)
Set --workdir option.- Parameters:
workdir
- the working directory- Returns:
- the self
-
setNetworkType
public DockerRunCommand setNetworkType(String type)
Set --net option.- Parameters:
type
- the network type- Returns:
- the self
-
addReadWriteMountLocation
public DockerRunCommand addReadWriteMountLocation(String sourcePath, String destinationPath, boolean createSource) throws IOException
Add bind mount locations.- Parameters:
sourcePath
- the source pathdestinationPath
- the destination pathcreateSource
- if createSource is false and the source path doesn't exist, do nothing- Returns:
- the self
- Throws:
IOException
-
addReadWriteMountLocation
public DockerRunCommand addReadWriteMountLocation(String sourcePath, String destinationPath) throws IOException
- Throws:
IOException
-
addAllReadWriteMountLocations
public DockerRunCommand addAllReadWriteMountLocations(List<String> paths) throws IOException
Add all the rw bind mount locations.- Parameters:
paths
- the locations- Returns:
- the self
- Throws:
IOException
-
addAllReadWriteMountLocations
public DockerRunCommand addAllReadWriteMountLocations(List<String> paths, boolean createSource) throws IOException
Add all the rw bind mount locations.- Parameters:
paths
- the locationscreateSource
- if createSource is false and the source path doesn't exist, do nothing- Returns:
- the self
- Throws:
IOException
-
addReadOnlyMountLocation
public DockerRunCommand addReadOnlyMountLocation(String sourcePath, String destinationPath, boolean createSource) throws IOException
Add readonly bind mount location.- Parameters:
sourcePath
- the source pathdestinationPath
- the destination pathcreateSource
- if createSource is false and the source path doesn't exist, do nothing- Returns:
- the self
- Throws:
IOException
-
addReadOnlyMountLocation
public DockerRunCommand addReadOnlyMountLocation(String sourcePath, String destinationPath) throws IOException
Add readonly bind mout location.- Parameters:
sourcePath
- the source pathdestinationPath
- the destination path- Returns:
- the self
- Throws:
IOException
-
addAllReadOnlyMountLocations
public DockerRunCommand addAllReadOnlyMountLocations(List<String> paths) throws IOException
Add all readonly locations.- Parameters:
paths
- the locations- Returns:
- the self
- Throws:
IOException
-
addAllReadOnlyMountLocations
public DockerRunCommand addAllReadOnlyMountLocations(List<String> paths, boolean createSource) throws IOException
Add all readonly locations.- Parameters:
paths
- the locationscreateSource
- if createSource is false and the source path doesn't exist, do nothing- Returns:
- the self
- Throws:
IOException
-
addCpuSetBindings
public DockerRunCommand addCpuSetBindings(List<String> cores, String memoryNode)
-
setCGroupParent
public DockerRunCommand setCGroupParent(String parentPath)
Set --cgroup-parent option.- Parameters:
parentPath
- the cgroup parent path- Returns:
- the self
-
setPrivileged
public DockerRunCommand setPrivileged()
Set --privileged option to run a privileged container. Use with extreme care.- Returns:
- the self.
-
setCapabilities
public DockerRunCommand setCapabilities(Set<String> capabilities)
Set capabilities of the container.- Parameters:
capabilities
- the capabilities to be added- Returns:
- the self
-
addDevice
public DockerRunCommand addDevice(String sourceDevice, String destinationDevice)
Set --device option.- Parameters:
sourceDevice
- the source devicedestinationDevice
- the destination device- Returns:
- the self
-
enableDetach
public DockerRunCommand enableDetach()
Enable detach.- Returns:
- the self
-
disableDetach
public DockerRunCommand disableDetach()
Disable detach.- Returns:
- the self
-
groupAdd
public DockerRunCommand groupAdd(String[] groups)
Set --group-add option.- Parameters:
groups
- the groups to be added- Returns:
- the self
-
setOverrideCommandWithArgs
public DockerRunCommand setOverrideCommandWithArgs(List<String> overrideCommandWithArgs)
Set extra commands and args. It can override the existing commands.- Parameters:
overrideCommandWithArgs
- the extra commands and args- Returns:
- the self
-
setReadonly
public DockerRunCommand setReadonly()
Add --read-only option.- Returns:
- the self
-
setSeccompProfile
public DockerRunCommand setSeccompProfile(String jsonPath)
Set --security-opt option.- Parameters:
jsonPath
- the path to the json file- Returns:
- the self
-
setNoNewPrivileges
public DockerRunCommand setNoNewPrivileges()
Set no-new-privileges option.- Returns:
- the self
-
setCpuShares
public DockerRunCommand setCpuShares(int cpuShares)
Set cpuShares.- Parameters:
cpuShares
- the cpu shares- Returns:
- the self
-
setCpus
public DockerRunCommand setCpus(double cpus)
Set the number of cpus to use.- Parameters:
cpus
- the number of cpus- Returns:
- the self
-
setMemoryMb
public DockerRunCommand setMemoryMb(int memoryMb)
Set the number of memory in MB to use.- Parameters:
memoryMb
- the number of memory in MB- Returns:
- the self
-
setCidFile
public DockerRunCommand setCidFile(String cidFile)
Set the output container id file location.- Parameters:
cidFile
- the container id file- Returns:
- the self
-
getCommandWithArguments
public String getCommandWithArguments()
Get the full command.- Overrides:
getCommandWithArguments
in classDockerCommand
- Returns:
- the full command
-
-