public class DockerRunCommand extends DockerCommand
Encapsulates the docker run command and its command line arguments.
| Constructor and Description |
|---|
DockerRunCommand(String containerName,
String userInfo,
String image)
The Construction function.
|
| Modifier and Type | Method and 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.
|
addCommandArguments, getCommandOptionpublic DockerRunCommand removeContainerOnExit()
Add –rm option.
public DockerRunCommand detachOnRun()
Add -d option.
public DockerRunCommand setContainerWorkDir(String workdir)
Set –workdir option.
workdir - the working directorypublic DockerRunCommand setNetworkType(String type)
Set –net option.
type - the network typepublic DockerRunCommand addReadWriteMountLocation(String sourcePath, String destinationPath, boolean createSource) throws IOException
Add bind mount locations.
sourcePath - the source pathdestinationPath - the destination pathcreateSource - if createSource is false and the source path doesn’t exist, do nothingIOExceptionpublic DockerRunCommand addReadWriteMountLocation(String sourcePath, String destinationPath) throws IOException
IOExceptionpublic DockerRunCommand addAllReadWriteMountLocations(List<String> paths) throws IOException
Add all the rw bind mount locations.
paths - the locationsIOExceptionpublic DockerRunCommand addAllReadWriteMountLocations(List<String> paths, boolean createSource) throws IOException
Add all the rw bind mount locations.
paths - the locationscreateSource - if createSource is false and the source path doesn’t exist, do nothingIOExceptionpublic DockerRunCommand addReadOnlyMountLocation(String sourcePath, String destinationPath, boolean createSource) throws IOException
Add readonly bind mount location.
sourcePath - the source pathdestinationPath - the destination pathcreateSource - if createSource is false and the source path doesn’t exist, do nothingIOExceptionpublic DockerRunCommand addReadOnlyMountLocation(String sourcePath, String destinationPath) throws IOException
Add readonly bind mout location.
sourcePath - the source pathdestinationPath - the destination pathIOExceptionpublic DockerRunCommand addAllReadOnlyMountLocations(List<String> paths) throws IOException
Add all readonly locations.
paths - the locationsIOExceptionpublic DockerRunCommand addAllReadOnlyMountLocations(List<String> paths, boolean createSource) throws IOException
Add all readonly locations.
paths - the locationscreateSource - if createSource is false and the source path doesn’t exist, do nothingIOExceptionpublic DockerRunCommand addCpuSetBindings(List<String> cores, String memoryNode)
public DockerRunCommand setCGroupParent(String parentPath)
Set –cgroup-parent option.
parentPath - the cgroup parent pathpublic DockerRunCommand setPrivileged()
Set –privileged option to run a privileged container. Use with extreme care.
public DockerRunCommand setCapabilities(Set<String> capabilities)
Set capabilities of the container.
capabilities - the capabilities to be addedpublic DockerRunCommand addDevice(String sourceDevice, String destinationDevice)
Set –device option.
sourceDevice - the source devicedestinationDevice - the destination devicepublic DockerRunCommand enableDetach()
Enable detach.
public DockerRunCommand disableDetach()
Disable detach.
public DockerRunCommand groupAdd(String[] groups)
Set –group-add option.
groups - the groups to be addedpublic DockerRunCommand setOverrideCommandWithArgs(List<String> overrideCommandWithArgs)
Set extra commands and args. It can override the existing commands.
overrideCommandWithArgs - the extra commands and argspublic DockerRunCommand setReadonly()
Add –read-only option.
public DockerRunCommand setSeccompProfile(String jsonPath)
Set –security-opt option.
jsonPath - the path to the json filepublic DockerRunCommand setNoNewPrivileges()
Set no-new-privileges option.
public DockerRunCommand setCpuShares(int cpuShares)
Set cpuShares.
cpuShares - the cpu sharespublic DockerRunCommand setCpus(double cpus)
Set the number of cpus to use.
cpus - the number of cpuspublic DockerRunCommand setMemoryMb(int memoryMb)
Set the number of memory in MB to use.
memoryMb - the number of memory in MBpublic DockerRunCommand setCidFile(String cidFile)
Set the output container id file location.
cidFile - the container id filepublic String getCommandWithArguments()
Get the full command.
getCommandWithArguments in class DockerCommandCopyright © 2021 The Apache Software Foundation. All rights reserved.