com.kpelykh.docker.client
Class DockerClient

java.lang.Object
  extended by com.kpelykh.docker.client.DockerClient

public class DockerClient
extends Object

Author:
Konstantin Pelykh ([email protected])

Constructor Summary
DockerClient()
           
DockerClient(String serverUrl)
           
 
Method Summary
static String asString(com.sun.jersey.api.client.ClientResponse response)
           
 void auth()
          Authenticate with the server, useful for checking authentication.
 AuthConfig authConfig()
           
 com.sun.jersey.api.client.ClientResponse build(File dockerFolder)
           
 com.sun.jersey.api.client.ClientResponse build(File dockerFolder, String tag)
           
 com.sun.jersey.api.client.ClientResponse build(File dockerFolder, String tag, boolean noCache)
           
 String commit(CommitConfig commitConfig)
           
 List<ChangeLog> containerDiff(String containerId)
           
 com.sun.jersey.api.client.ClientResponse copyFile(String containerId, String resource)
           
 ContainerCreateResponse createContainer(ContainerConfig config)
           
 ContainerCreateResponse createContainer(ContainerConfig config, String name)
           
 List<Image> getImages()
           
 List<Image> getImages(boolean allContainers)
           
 List<Image> getImages(String name)
           
 List<Image> getImages(String name, boolean allImages)
           
 String getVizImages()
           
 ImageCreateResponse importImage(String repository, String tag, InputStream imageStream)
          Create an image by importing the given stream of a tar file.
 Info info()
          * MISC API *
 ContainerInspectResponse inspectContainer(String containerId)
           
 ImageInspectResponse inspectImage(String imageId)
           
 void kill(String containerId)
           
 List<Container> listContainers(boolean allContainers)
          * CONTAINER API *
 List<Container> listContainers(boolean allContainers, boolean latest)
           
 List<Container> listContainers(boolean allContainers, boolean latest, int limit)
           
 List<Container> listContainers(boolean allContainers, boolean latest, int limit, boolean showSize)
           
 List<Container> listContainers(boolean allContainers, boolean latest, int limit, boolean showSize, String since)
           
 List<Container> listContainers(boolean allContainers, boolean latest, int limit, boolean showSize, String since, String before)
           
 com.sun.jersey.api.client.ClientResponse logContainer(String containerId)
           
 com.sun.jersey.api.client.ClientResponse logContainerStream(String containerId)
           
 int ping()
           
 com.sun.jersey.api.client.ClientResponse pull(String repository)
          * IMAGE API *
 com.sun.jersey.api.client.ClientResponse pull(String repository, String tag)
           
 com.sun.jersey.api.client.ClientResponse pull(String repository, String tag, String registry)
           
 com.sun.jersey.api.client.ClientResponse push(String name)
          Push the latest image to the repository.
 void removeContainer(String container)
           
 void removeContainer(String containerId, boolean removeVolumes)
           
 void removeContainers(List<String> containers, boolean removeVolumes)
           
 void removeImage(String imageId)
          Remove an image, deleting any tags it might have.
 void removeImages(List<String> images)
           
 void restart(String containerId, int timeout)
           
 List<SearchItem> search(String search)
           
 void setCredentials(String username, String password, String email)
           
 void startContainer(String containerId)
           
 void startContainer(String containerId, HostConfig hostConfig)
           
 void stopContainer(String containerId)
           
 void stopContainer(String containerId, int timeout)
           
 int tag(String image, String repository, String tag, boolean force)
          Tag an image into a repository
 Version version()
           
 int waitContainer(String containerId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockerClient

public DockerClient()
             throws DockerException
Throws:
DockerException

DockerClient

public DockerClient(String serverUrl)
             throws DockerException
Throws:
DockerException
Method Detail

setCredentials

public void setCredentials(String username,
                           String password,
                           String email)

auth

public void auth()
          throws DockerException
Authenticate with the server, useful for checking authentication.

Throws:
DockerException

authConfig

public AuthConfig authConfig()
                      throws DockerException
Throws:
DockerException

info

public Info info()
          throws DockerException
* MISC API *

Throws:
DockerException

version

public Version version()
                throws DockerException
Throws:
DockerException

ping

public int ping()
         throws DockerException
Throws:
DockerException

pull

public com.sun.jersey.api.client.ClientResponse pull(String repository)
                                              throws DockerException
* IMAGE API *

Throws:
DockerException

pull

public com.sun.jersey.api.client.ClientResponse pull(String repository,
                                                     String tag)
                                              throws DockerException
Throws:
DockerException

pull

public com.sun.jersey.api.client.ClientResponse pull(String repository,
                                                     String tag,
                                                     String registry)
                                              throws DockerException
Throws:
DockerException

asString

public static String asString(com.sun.jersey.api.client.ClientResponse response)
                       throws IOException
Returns:
The output slurped into a string.
Throws:
IOException

push

public com.sun.jersey.api.client.ClientResponse push(String name)
                                              throws DockerException
Push the latest image to the repository.

Parameters:
name - The name, e.g. "alexec/busybox" or just "busybox" if you want to default. Not null.
Throws:
DockerException

tag

public int tag(String image,
               String repository,
               String tag,
               boolean force)
        throws DockerException
Tag an image into a repository

Parameters:
image - the local image to tag (either a name or an id)
repository - the repository to tag in
tag - any tag for this image
force - (not documented)
Returns:
the HTTP status code (201 for success)
Throws:
DockerException

importImage

public ImageCreateResponse importImage(String repository,
                                       String tag,
                                       InputStream imageStream)
                                throws DockerException
Create an image by importing the given stream of a tar file.

Parameters:
repository - the repository to import to
tag - any tag for this image
imageStream - the InputStream of the tar file
Returns:
an ImageCreateResponse containing the id of the imported image
Throws:
DockerException - if the import fails for some reason.

search

public List<SearchItem> search(String search)
                        throws DockerException
Throws:
DockerException

removeImage

public void removeImage(String imageId)
                 throws DockerException
Remove an image, deleting any tags it might have.

Throws:
DockerException

removeImages

public void removeImages(List<String> images)
                  throws DockerException
Throws:
DockerException

getVizImages

public String getVizImages()
                    throws DockerException
Throws:
DockerException

getImages

public List<Image> getImages()
                      throws DockerException
Throws:
DockerException

getImages

public List<Image> getImages(boolean allContainers)
                      throws DockerException
Throws:
DockerException

getImages

public List<Image> getImages(String name)
                      throws DockerException
Throws:
DockerException

getImages

public List<Image> getImages(String name,
                             boolean allImages)
                      throws DockerException
Throws:
DockerException

inspectImage

public ImageInspectResponse inspectImage(String imageId)
                                  throws DockerException,
                                         NotFoundException
Throws:
DockerException
NotFoundException

listContainers

public List<Container> listContainers(boolean allContainers)
* CONTAINER API *


listContainers

public List<Container> listContainers(boolean allContainers,
                                      boolean latest)

listContainers

public List<Container> listContainers(boolean allContainers,
                                      boolean latest,
                                      int limit)

listContainers

public List<Container> listContainers(boolean allContainers,
                                      boolean latest,
                                      int limit,
                                      boolean showSize)

listContainers

public List<Container> listContainers(boolean allContainers,
                                      boolean latest,
                                      int limit,
                                      boolean showSize,
                                      String since)

listContainers

public List<Container> listContainers(boolean allContainers,
                                      boolean latest,
                                      int limit,
                                      boolean showSize,
                                      String since,
                                      String before)

createContainer

public ContainerCreateResponse createContainer(ContainerConfig config)
                                        throws DockerException
Throws:
DockerException

createContainer

public ContainerCreateResponse createContainer(ContainerConfig config,
                                               String name)
                                        throws DockerException,
                                               NotFoundException
Throws:
DockerException
NotFoundException

startContainer

public void startContainer(String containerId)
                    throws DockerException
Throws:
DockerException

startContainer

public void startContainer(String containerId,
                           HostConfig hostConfig)
                    throws DockerException,
                           NotFoundException
Throws:
DockerException
NotFoundException

inspectContainer

public ContainerInspectResponse inspectContainer(String containerId)
                                          throws DockerException,
                                                 NotFoundException
Throws:
DockerException
NotFoundException

removeContainer

public void removeContainer(String container)
                     throws DockerException
Throws:
DockerException

removeContainer

public void removeContainer(String containerId,
                            boolean removeVolumes)
                     throws DockerException
Throws:
DockerException

removeContainers

public void removeContainers(List<String> containers,
                             boolean removeVolumes)
                      throws DockerException
Throws:
DockerException

waitContainer

public int waitContainer(String containerId)
                  throws DockerException,
                         NotFoundException
Throws:
DockerException
NotFoundException

logContainer

public com.sun.jersey.api.client.ClientResponse logContainer(String containerId)
                                                      throws DockerException
Throws:
DockerException

logContainerStream

public com.sun.jersey.api.client.ClientResponse logContainerStream(String containerId)
                                                            throws DockerException
Throws:
DockerException

copyFile

public com.sun.jersey.api.client.ClientResponse copyFile(String containerId,
                                                         String resource)
                                                  throws DockerException
Throws:
DockerException

containerDiff

public List<ChangeLog> containerDiff(String containerId)
                              throws DockerException,
                                     NotFoundException
Throws:
DockerException
NotFoundException

stopContainer

public void stopContainer(String containerId)
                   throws DockerException
Throws:
DockerException

stopContainer

public void stopContainer(String containerId,
                          int timeout)
                   throws DockerException
Throws:
DockerException

kill

public void kill(String containerId)
          throws DockerException
Throws:
DockerException

restart

public void restart(String containerId,
                    int timeout)
             throws DockerException,
                    NotFoundException
Throws:
DockerException
NotFoundException

commit

public String commit(CommitConfig commitConfig)
              throws DockerException,
                     NotFoundException
Throws:
DockerException
NotFoundException

build

public com.sun.jersey.api.client.ClientResponse build(File dockerFolder)
                                               throws DockerException
Throws:
DockerException

build

public com.sun.jersey.api.client.ClientResponse build(File dockerFolder,
                                                      String tag)
                                               throws DockerException
Throws:
DockerException

build

public com.sun.jersey.api.client.ClientResponse build(File dockerFolder,
                                                      String tag,
                                                      boolean noCache)
                                               throws DockerException
Throws:
DockerException


Copyright © 2014. All rights reserved.