You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
URL resourceUrl =
UploadBinaryScanRecorder.class.getClassLoader().getResource("com/fs/docker/Dockerfile");
// Docker client configuration
DefaultDockerClientConfig config =
DefaultDockerClientConfig.createDefaultConfigBuilder().build();
DockerClient dockerClient = DockerClientBuilder.getInstance(config).build();
BuildImageCmd buildImageCmd = dockerClient.buildImageCmd();
// Step 2: Set the Dockerfile
buildImageCmd.withDockerfile(new File(resourceUrl.getFile()));
// Step 3: Execute the build and get the result callback
BuildImageResultCallback resultCallback = new BuildImageResultCallback() {
@Override
public void onNext(com.github.dockerjava.api.model.BuildResponseItem item) {
// Handle build response
System.out.println(item.getStream());
}
};
buildImageCmd.exec(resultCallback);
// Step 4: Await the image ID
String imageId = resultCallback.awaitImageId(); // line 215
The exception was trigger in the line 215: String imageId = resultCallback.awaitImageId();
I confirmed that the image was build successfully:
Step 1/2 : FROM python:3.9-alpine
---> 8f4429cefc37
Step 2/2 : ENTRYPOINT [ "python3","--version"]
---> Using cache
---> a6b29bfb7257
null
Successfully built a6b29bfb7257
But I got this error and I don't understand why:
ERROR: Build step failed with exception
com.github.dockerjava.api.exception.DockerClientException: Could not build image
at com.github.dockerjava.core.command.BuildImageResultCallback.getImageId(BuildImageResultCallback.java:77)
at com.github.dockerjava.core.command.BuildImageResultCallback.awaitImageId(BuildImageResultCallback.java:52)
at com.finitestate.uploadbinaryscan.XXXX.perform(UploadBinaryScanRecorder.java:215)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:47)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
at hudson.model.Build$BuildExecution.post2(Build.java:179)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:711)
at hudson.model.Run.execute(Run.java:1925)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
I need to get the imageId in order to run it later.
Thanks!
The text was updated successfully, but these errors were encountered:
Hello I'm tring to build and run an image from a docker file using java. For that I have this dependencies in maven:
I'm using this code:
The exception was trigger in the line 215:
String imageId = resultCallback.awaitImageId();
I confirmed that the image was build successfully:
But I got this error and I don't understand why:
I need to get the imageId in order to run it later.
Thanks!
The text was updated successfully, but these errors were encountered: