I am trying to load image to docker from tar file and verify if the tar file is valid or not. Now if tar file is valid I need to get the imageName and tag.
But I checked and the return type for exec method is void. Does anyone know how can I get the imageName and tag.
@Autowired
private DockerClient dockerClient;
public void loadImage(InputStream inputStream) {
dockerClient.loadImageCmd(inputStream).exec();
}
I am using below library
com.github.docker-java:docker-java:3.2.5
com.github.docker-java:docker-java-transport-httpclient5:3.2
This question is already asked here and they return void for loadImageCmd. I found a workaround for this.
If we have the tar file stored in some location we can then read the manifest file and get the repo name from that.
I used below dependecy to extract inputStream of manifest.json
Once you get the input stream convert this inputstream to JSONArray object and get the repoTag.
Used below dependency to convert inputStream to JsonArray object.