Class DockerCloud

    • Method Detail

      • getDockerApi

        public DockerAPI getDockerApi()
      • getConnectTimeout

        @Deprecated
        public int getConnectTimeout()
        Deprecated.
      • getDockerHost

        @Deprecated
        public org.jenkinsci.plugins.docker.commons.credentials.DockerServerEndpoint getDockerHost()
        Deprecated.
      • getContainerCap

        public int getContainerCap()
      • setContainerCap

        @DataBoundSetter
        public void setContainerCap​(int containerCap)
      • sanitizeUrl

        protected String sanitizeUrl​(String url)
      • getClient

        @Deprecated
        public com.github.dockerjava.api.DockerClient getClient()
        Deprecated.
        Use getDockerApi() and then DockerAPI.getClient() to get the client, followed by a call to DockerClient.close().
        Connects to Docker. NOTE: This should not be used for any long-running operations as the client it returns is not protected from closure.
        Returns:
        Docker client.
      • countContainersInProgress

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public int countContainersInProgress​(DockerTemplate template)
      • runContainer

        public static String runContainer​(DockerTemplateBase dockerTemplateBase,
                                          com.github.dockerjava.api.DockerClient dockerClient)
      • addTemplate

        public void addTemplate​(DockerTemplate t)
        Add a new template to the cloud
        Parameters:
        t - The template to be added.
      • addJobTemplate

        public void addJobTemplate​(long jobId,
                                   DockerTemplate template)
        Adds a template which is temporary provided and bound to a specific job.
        Parameters:
        jobId - Unique id (per master) of the job to which the template is bound.
        template - The template to bound to a specific job.
      • removeJobTemplate

        public void removeJobTemplate​(long jobId)
        Removes a template which is bound to a specific job.
        Parameters:
        jobId - Id of the job.
      • getTemplates

        public List<DockerTemplate> getTemplates​(Label label)
        Multiple amis can have the same label.
        Parameters:
        label - The label to be matched, or null if no label was provided.
        Returns:
        Templates matched to requested label assuming agent Mode
      • removeTemplate

        public void removeTemplate​(DockerTemplate t)
        Remove Docker template
        Parameters:
        t - The template to be removed.
      • countContainersInDocker

        public int countContainersInDocker​(String imageName)
                                    throws Exception
        Counts the number of instances currently running in Docker that are using the specified image.

        WARNING: This method can be slow so it should be called sparingly.

        Parameters:
        imageName - If null, then all instances belonging to this Jenkins instance are counted. Otherwise, only those started with the specified image are counted.
        Returns:
        The number of containers.
        Throws:
        Exception - if anything went wrong.
      • getCloudByName

        @CheckForNull
        public static DockerCloud getCloudByName​(String name)
      • readResolve

        protected Object readResolve()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isTriton

        public boolean isTriton()
      • isExposeDockerHost

        public boolean isExposeDockerHost()
      • setExposeDockerHost

        @DataBoundSetter
        public void setExposeDockerHost​(boolean exposeDockerHost)
      • setDisabled

        @DataBoundSetter
        public void setDisabled​(DockerDisabled disabled)
      • getErrorDuration

        @CheckForNull
        public Integer getErrorDuration()
      • setErrorDuration

        @DataBoundSetter
        public void setErrorDuration​(Integer errorDuration)
      • setRegistryAuthentication

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static void setRegistryAuthentication​(com.github.dockerjava.api.command.PullImageCmd cmd,
                                                     org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint registry,
                                                     ItemGroup context)
      • setRegistryAuthentication

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static void setRegistryAuthentication​(com.github.dockerjava.api.command.PushImageCmd cmd,
                                                     org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint registry,
                                                     ItemGroup context)
      • getAuthConfig

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static com.github.dockerjava.api.model.AuthConfig getAuthConfig​(org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint registry,
                                                                               ItemGroup context)