public class RunService extends Object
Constructor and Description |
---|
RunService(DockerAccess docker,
QueryService queryService,
ContainerTracker tracker,
LogOutputSpecFactory logConfig,
Logger log) |
Modifier and Type | Method and Description |
---|---|
void |
addShutdownHookForStoppingContainers(boolean keepContainer,
boolean removeVolumes,
boolean removeCustomNetworks)
Add a shutdown hook in order to stop all registered containers
|
String |
createAndStartContainer(ImageConfiguration imageConfig,
PortMapping portMapping,
PomLabel pomLabel,
Properties mavenProps,
File baseDir)
Create and start a container with the given image configuration.
|
void |
createCustomNetworkIfNotExistant(String customNetwork) |
PortMapping |
createPortMapping(RunImageConfiguration runConfig,
Properties properties)
Create port mapping for a specific configuration as it can be used when creating containers
|
String |
execInContainer(String containerId,
String command,
ImageConfiguration imageConfiguration)
Create and start a Exec container with the given image configuration.
|
List<StartOrderResolver.Resolvable> |
getImagesConfigsInOrder(QueryService queryService,
List<ImageConfiguration> images)
Get the proper order for images to start
|
String |
lookupContainer(String lookup)
Lookup a container that has been started
|
void |
removeCustomNetworks(Collection<Network> networks) |
void |
stopContainer(String containerId,
ImageConfiguration imageConfig,
boolean keepContainer,
boolean removeVolumes)
Stop a container immediately by id.
|
void |
stopPreviouslyStartedContainer(String containerId,
boolean keepContainer,
boolean removeVolumes)
Lookup up whether a certain has been already started and registered.
|
void |
stopStartedContainers(boolean keepContainer,
boolean removeVolumes,
boolean removeCustomNetworks,
PomLabel pomLabel)
Stop all registered container
|
public RunService(DockerAccess docker, QueryService queryService, ContainerTracker tracker, LogOutputSpecFactory logConfig, Logger log)
public String execInContainer(String containerId, String command, ImageConfiguration imageConfiguration) throws DockerAccessException
containerId
- container id to run exec command againstcommand
- command to executeimageConfiguration
- configuration of the container's imageDockerAccessException
- if access to the docker backend failspublic String createAndStartContainer(ImageConfiguration imageConfig, PortMapping portMapping, PomLabel pomLabel, Properties mavenProps, File baseDir) throws DockerAccessException
imageConfig
- image configuration holding the run information and the image nameportMapping
- container port mappingmavenProps
- properties to fill in with dynamically assigned portspomLabel
- label to tag the started container withDockerAccessException
- if access to the docker backend failspublic void stopContainer(String containerId, ImageConfiguration imageConfig, boolean keepContainer, boolean removeVolumes) throws DockerAccessException
containerId
- the container to stopimageConfig
- image configuration for this containerkeepContainer
- whether to keep container or to remove them after stoppingsremoveVolumes
- whether to remove volumes after stoppingDockerAccessException
public void stopPreviouslyStartedContainer(String containerId, boolean keepContainer, boolean removeVolumes) throws DockerAccessException
containerId
- the container to stopkeepContainer
- whether to keep container or to remove them after stoppingsremoveVolumes
- whether to remove volumes after stoppingDockerAccessException
public void stopStartedContainers(boolean keepContainer, boolean removeVolumes, boolean removeCustomNetworks, PomLabel pomLabel) throws DockerAccessException
keepContainer
- whether to keep container or to remove them after stoppingsremoveVolumes
- whether to remove volumes after stoppingDockerAccessException
- if during stopping of a container sth failspublic String lookupContainer(String lookup)
lookup
- a container by id or aliasnull
otherwise.public List<StartOrderResolver.Resolvable> getImagesConfigsInOrder(QueryService queryService, List<ImageConfiguration> images)
images
- list of images for which the order should be createdpublic PortMapping createPortMapping(RunImageConfiguration runConfig, Properties properties)
runConfig
- the cun configurationproperties
- properties to lookup variablespublic void addShutdownHookForStoppingContainers(boolean keepContainer, boolean removeVolumes, boolean removeCustomNetworks)
public void createCustomNetworkIfNotExistant(String customNetwork) throws DockerAccessException
DockerAccessException
public void removeCustomNetworks(Collection<Network> networks) throws DockerAccessException
DockerAccessException
Copyright © 2020. All rights reserved.