public interface DockerAccess
Modifier and Type | Method and Description |
---|---|
void |
buildImage(String image,
File dockerArchive,
BuildOptions options)
Create an docker image from a given archive
|
void |
copyArchive(String containerId,
File archive,
String targetPath)
Copy an archive (must be a tar) into a running container
Get all containers matching a certain label.
|
String |
createContainer(ContainerCreateConfig configuration,
String containerName)
Create a container from the given image.
|
String |
createExecContainer(String containerId,
org.eclipse.jkube.kit.config.image.build.Arguments arguments)
Sets up an exec instance for a running container id
|
String |
createNetwork(NetworkCreateConfig configuration)
Create a custom network from the given configuration.
|
String |
createVolume(VolumeCreateConfig configuration)
Create a volume
|
ContainerDetails |
getContainer(String containerIdOrName)
Get a container
|
List<Container> |
getContainersForImage(String image,
boolean all)
Get all containers which are build from an image.
|
ExecDetails |
getExecContainer(String containerIdOrName)
Get an exec container which is the result of executing a command in a running container.
|
String |
getImageId(String name)
Get the image id of a given name or
null if no such image exists |
LogGetHandle |
getLogAsync(String containerId,
LogCallback callback)
Get logs asynchronously.
|
void |
getLogSync(String containerId,
LogCallback callback)
Get logs for a container up to now synchronously.
|
String |
getServerApiVersion()
Get the API version of the running server
|
boolean |
hasImage(String name)
Check whether the given name exists as image at the docker daemon
|
List<Network> |
listNetworks()
List all networks
|
void |
loadImage(String image,
File tarArchive)
Load an image from an archive.
|
void |
pullImage(String image,
AuthConfig authConfig,
String registry)
Pull an image from a remote registry and store it locally.
|
void |
pushImage(String image,
AuthConfig authConfig,
String registry,
int retries)
Push an image to a registry.
|
void |
removeContainer(String containerId,
boolean removeVolumes)
Remove a container with the given id
|
boolean |
removeImage(String image,
boolean... force)
Remove an image from this docker installation
|
boolean |
removeNetwork(String networkId)
Remove a custom network
|
void |
removeVolume(String name)
Removes a volume.
|
void |
saveImage(String image,
String filename,
org.eclipse.jkube.kit.config.image.build.ArchiveCompression compression)
Save an image to a tar file
|
void |
shutdown()
Lifecycle method which must be called when this object is not needed anymore.
|
void |
start()
Lifecycle method for this access class which must be called before any other method is called.
|
void |
startContainer(String containerId)
Start a container.
|
void |
startExecContainer(String containerId,
LogOutputSpec outputSpec)
Starts a previously set up exec instance (via
createExecContainer(String, Arguments) container
this API sets up a session with the exec command. |
void |
stopContainer(String containerId,
int killWait)
Stop a container.
|
void |
tag(String sourceImage,
String targetImage,
boolean force)
Alias an image in the repository with a complete new name.
|
String getServerApiVersion() throws DockerAccessException
DockerAccessException
- if the api version could not be obtainedContainerDetails getContainer(String containerIdOrName) throws DockerAccessException
containerIdOrName
- container id or nameContainerDetails
representing the container or null if none could be foundDockerAccessException
- if the container could not be inspectedExecDetails getExecContainer(String containerIdOrName) throws DockerAccessException
containerIdOrName
- exec container id or nameExecDetails
representing the container or null if none could be foundDockerAccessException
- if the container could not be inspectedboolean hasImage(String name) throws DockerAccessException
name
- image name to checkDockerAccessException
- docker access exceptionString getImageId(String name) throws DockerAccessException
null
if no such image existsname
- name to lookupnull
DockerAccessException
- docker access exceptionList<Container> getContainersForImage(String image, boolean all) throws DockerAccessException
image
- for which its container are looked upall
- whether to fetch also stopped containers. If false only running containers are returnedContainer
objects or an empty list if none is foundDockerAccessException
- if the request failsvoid startExecContainer(String containerId, LogOutputSpec outputSpec) throws DockerAccessException
createExecContainer(String, Arguments)
container
this API sets up a session with the exec command. Output is streamed to the log. This methods
returns only when the exec command has finished (i.e this method calls the command in a non-detached mode).containerId
- id of the exec containeroutputSpec
- how to print out the output of the commandDockerAccessException
- if the container could not be created.String createExecContainer(String containerId, org.eclipse.jkube.kit.config.image.build.Arguments arguments) throws DockerAccessException
containerId
- id of the running container which the exec container will be created forarguments
- container exec commands to runDockerAccessException
- if the container could not be created.String createContainer(ContainerCreateConfig configuration, String containerName) throws DockerAccessException
The container id
will be set on the container
upon successful creation.
configuration
- container configurationcontainerName
- name container should be created with or null
for a docker provided nameDockerAccessException
- if the container could not be created.void startContainer(String containerId) throws DockerAccessException
containerId
- id of the container to startDockerAccessException
- if the container could not be started.void stopContainer(String containerId, int killWait) throws DockerAccessException
containerId
- the container idkillWait
- the time to wait between stop and kill (in seconds)DockerAccessException
- if the container could not be stopped.void copyArchive(String containerId, File archive, String targetPath) throws DockerAccessException
containerId
- container to copy intoarchive
- local archive to copy intotargetPath
- target path to useDockerAccessException
- if the archive could not be copiedvoid getLogSync(String containerId, LogCallback callback)
containerId
- container idcallback
- which is called for each line receivedLogGetHandle getLogAsync(String containerId, LogCallback callback)
containerId
- id of the container for which to fetch the logscallback
- to call when log data arrivesvoid removeContainer(String containerId, boolean removeVolumes) throws DockerAccessException
containerId
- container id for the container to removeremoveVolumes
- if true, will remove any volumes associated to containerDockerAccessException
- if the container couldn't be removed.void loadImage(String image, File tarArchive) throws DockerAccessException
image
- the image to pull.tarArchive
- archive fileDockerAccessException
- if the image couldn't be loaded.void pullImage(String image, AuthConfig authConfig, String registry) throws DockerAccessException
image
- the image to pull.authConfig
- authentication configuration used when pulling an imageregistry
- an optional registry from where to pull the image. Can be null.DockerAccessException
- if the image couldn't be pulled.void pushImage(String image, AuthConfig authConfig, String registry, int retries) throws DockerAccessException
image
- image name to pushauthConfig
- authentication configurationregistry
- optional registry to which the image should be pushed.retries
- optional number of times the push should be retried on a 500 errorDockerAccessException
- in case pushing failsvoid buildImage(String image, File dockerArchive, BuildOptions options) throws DockerAccessException
image
- name of the image to build or null
if none should be useddockerArchive
- from which the docker image should be buildoptions
- additional query arguments to add when building the image. Can be null.DockerAccessException
- if docker host reports an error during building of an imagevoid tag(String sourceImage, String targetImage, boolean force) throws DockerAccessException
sourceImage
- full name (including tag) of the image to aliastargetImage
- the alias nameforce
- forced taggingDockerAccessException
- if the original image doesn't exist or another error occurs somehow.boolean removeImage(String image, boolean... force) throws DockerAccessException
image
- image to removeforce
- if set to true remove containers as well (only the first vararg is evaluated)DockerAccessException
- if an image cannot be removedvoid saveImage(String image, String filename, org.eclipse.jkube.kit.config.image.build.ArchiveCompression compression) throws DockerAccessException
image
- image to savefilename
- target filenamecompression
- compression to use for the archiveDockerAccessException
- if an image cannot be removedList<Network> listNetworks() throws DockerAccessException
Network
objectsDockerAccessException
- if the networks could not be listedString createNetwork(NetworkCreateConfig configuration) throws DockerAccessException
configuration
- network configurationDockerAccessException
- if the container could not be created.boolean removeNetwork(String networkId) throws DockerAccessException
networkId
- network to removeDockerAccessException
- if an image cannot be removedvoid start() throws DockerAccessException
DockerAccessException
- docker access exceptionvoid shutdown()
String createVolume(VolumeCreateConfig configuration) throws DockerAccessException
configuration
- volume configurationDockerAccessException
- if the volume could not be created.void removeVolume(String name) throws DockerAccessException
name
- volume name to removeDockerAccessException
- if the volume could not be removedCopyright © 2020. All rights reserved.