Package io.micronaut.maven.services
Class DockerService
java.lang.Object
io.micronaut.maven.services.DockerService
Provides methods to work with Docker images.
- Since:
- 1.1
- Author:
- Álvaro Sánchez-Mariscal
-
Constructor Summary
ConstructorsConstructorDescriptionDockerService(org.apache.maven.project.MavenProject mavenProject, JibConfigurationService jibConfigurationService) -
Method Summary
Modifier and TypeMethodDescriptionbuildImage(com.github.dockerjava.api.command.BuildImageCmd builder) Builds the Docker image from the givenBuildImageCmdbuilder.com.github.dockerjava.api.command.BuildImageCmdcom.github.dockerjava.api.command.BuildImageCmdbuildImageCmd(String dockerfileName) copyFromContainer(String imageId, String containerPath) Copies a file from the specified container path in the given image ID, into a temporal location.com.github.dockerjava.api.model.AuthConfiggetAuthConfigFor(String dockerImage, String username, String password) Loads the given Dockerfile as classpath resource and copies it into a temporary location in the target directory.loadDockerfileAsResource(String name, String targetFileName) Loads the given Dockerfile as classpath resource and copies it into a temporary location in the target directory.com.github.dockerjava.api.command.PushImageCmdpushImageCmd(String imageName) voidrunPrivilegedImageAndWait(String imageId, Integer timeoutSeconds, String checkpointNetworkName, String... binds) Creates a container based on a given image, and runs it.
-
Constructor Details
-
DockerService
@Inject public DockerService(org.apache.maven.project.MavenProject mavenProject, JibConfigurationService jibConfigurationService)
-
-
Method Details
-
buildImageCmd
public com.github.dockerjava.api.command.BuildImageCmd buildImageCmd(String dockerfileName) throws IOException - Parameters:
dockerfileName- the name of the Dockerfile to load- Returns:
- the
BuildImageCmdby loading the given Dockerfile as classpath resource. - Throws:
IOException
-
buildImageCmd
- Returns:
- a default
BuildImageCmd.
-
buildImage
Builds the Docker image from the givenBuildImageCmdbuilder.- Parameters:
builder- The builder to use.- Returns:
- The resulting image ID.
-
runPrivilegedImageAndWait
public void runPrivilegedImageAndWait(String imageId, Integer timeoutSeconds, String checkpointNetworkName, String... binds) throws IOException Creates a container based on a given image, and runs it.- Parameters:
imageId- the image to usetimeoutSeconds- the timeout in seconds for the container to finish executioncheckpointNetworkName- the name of the network to use for the containerbinds- the bind mounts to use- Throws:
IOException
-
copyFromContainer
Copies a file from the specified container path in the given image ID, into a temporal location.- Parameters:
imageId- The image ID.containerPath- The container path.- Returns:
- The temporal file.
-
loadDockerfileAsResource
Loads the given Dockerfile as classpath resource and copies it into a temporary location in the target directory.- Parameters:
name- the name of the Dockerfile.- Returns:
- the file where the Dockerfile was copied to.
- Throws:
IOException
-
loadDockerfileAsResource
Loads the given Dockerfile as classpath resource and copies it into a temporary location in the target directory.- Parameters:
name- the name of the Dockerfile.targetFileName- the name of the file to copy the Dockerfile to.- Returns:
- the file where the Dockerfile was copied to.
- Throws:
IOException
-
pushImageCmd
- Parameters:
imageName- the image name- Returns:
- a
PushImageCmdfrom the given image name.
-
getAuthConfigFor
public com.github.dockerjava.api.model.AuthConfig getAuthConfigFor(String dockerImage, String username, String password) - Parameters:
dockerImage- the image nameusername- the usernamepassword- the password- Returns:
- an
AuthConfigobject for the given image, username and password.
-