public class QueryService extends Object
| Constructor and Description |
|---|
QueryService(DockerAccess docker)
Constructor which gets its dependencies as args)
|
| Modifier and Type | Method and Description |
|---|---|
Container |
getContainer(String containerIdOrName)
Get a container running for a given container name.
|
String |
getContainerName(String containerId)
Get name for single container when the id is given
|
List<Container> |
getContainersForImage(String image,
boolean all)
Get all containers which are build from an image.
|
String |
getImageId(String imageName)
Finds the id of an image.
|
Container |
getLatestContainerForImage(String image)
Get the id of the latest container started for an image
|
Container |
getMandatoryContainer(String containerIdOrName)
Get container by id
|
Network |
getNetworkByName(String networkName)
Get a network for a given network name.
|
Set<Network> |
getNetworks()
Get all networks.
|
boolean |
hasContainer(String containerName)
Check whether a container with the given name exists
|
boolean |
hasImage(String name)
Check whether the given Image is locally available.
|
boolean |
hasNetwork(String networkName)
Check whether a network with the given name exists
|
List<Container> |
listContainers(boolean all)
List all containers on the Docker server.
|
List<Image> |
listImages(boolean all)
Get all images on the Docker server.
|
public QueryService(DockerAccess docker)
docker - remote access to docker daemonpublic Container getMandatoryContainer(String containerIdOrName) throws DockerAccessException
containerIdOrName - container id or nameDockerAccessException - if an error occurs or no container with this id or name existspublic Container getContainer(String containerIdOrName) throws DockerAccessException
containerIdOrName - name of container to lookupnull if no container is available.DockerAccessException - in case of an remote errorpublic Network getNetworkByName(String networkName) throws DockerAccessException
networkName - name of network to lookupnull if no network is available.DockerAccessException - in case of an remote errorpublic Set<Network> getNetworks() throws DockerAccessException
null if no network is available.DockerAccessException - in case of an remote errorpublic String getContainerName(String containerId) throws DockerAccessException
containerId - id of container to lookupDockerAccessException - if access to the docker daemon failspublic List<Container> listContainers(boolean all) throws DockerAccessException
all - if true, list stopped containers as well as running containers.Container objectsDockerAccessException - if the request failspublic List<Container> getContainersForImage(String image, boolean all) throws DockerAccessException
image - for which its container are looked upall - if true, fetch stopped containers as well as running containers.Container objectsDockerAccessException - if the request failspublic List<Image> listImages(boolean all) throws DockerAccessException
all - if true, fetch untagged images as well as tagged.Image objectsDockerAccessException - if the request failspublic String getImageId(String imageName) throws DockerAccessException
imageName - name of the image.DockerAccessException - if the request failspublic Container getLatestContainerForImage(String image) throws DockerAccessException
image - for which its container are looked upnull if no container has been started for this image.DockerAccessException - if the request failspublic boolean hasContainer(String containerName) throws DockerAccessException
containerName - container nameDockerAccessExceptionpublic boolean hasNetwork(String networkName) throws DockerAccessException
networkName - network nameDockerAccessExceptionpublic boolean hasImage(String name) throws DockerAccessException
name - name of image to check, the image can contain a tag, otherwise 'latest' will be appendedDockerAccessException - if the request failsCopyright © 2019. All rights reserved.