0

I'm asking some help to create local Docker images using jib-core.

I know how to push the image to a DockerHub Repo but now I want to get all the images into a local single repository.

What I've done so far:

  • By reading the jib-core doc, successfully create a image.tar but can't build it (missing the dockerfile)

for the moment this is how I do it:

public void buildLocalImage(String appName) throws InvalidImageReferenceException, IOException, InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException {
        Jib.from("openjdk:15")
                .addLayer(Arrays.asList(Paths.get("jars/"+appName+".jar")), AbsoluteUnixPath.get("/"))
                .addLayer(Arrays.asList(Paths.get("jars/local-kube-api.jar")), AbsoluteUnixPath.get("/"))
                .addLayer(Arrays.asList(Paths.get("jars/script.sh")), AbsoluteUnixPath.get("/"))
                .setEntrypoint("sh","/script.sh")
                .containerize(
                        Containerizer.to(DockerDaemonImage.named("images/"+appName+"-images:TEST")).setOfflineMode(true)
                );
    }

The ultimate goal is to run 2 jars in a single container, which run successfully when I'm using the traditional way which is to push to a dockerHub repo by adding credentials etc.

The code above run without error, but I can't find the image after it, and I don't know why.

I must have gone wrong somewhere. This is a university project, if you have any doc that I can read on these topics it would be of great help to me.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
N7Legend
  • 71
  • 9

1 Answers1

0
public void buildLocalImage(String appName) throws InvalidImageReferenceException, IOException, InterruptedException, ExecutionException, RegistryException, CacheDirectoryCreationException {
        Jib.from("openjdk:15")
                .addLayer(Arrays.asList(Paths.get("jars/"+appName+".jar")), AbsoluteUnixPath.get("/"))
                .addLayer(Arrays.asList(Paths.get("jars/local-kube-api.jar")), AbsoluteUnixPath.get("/"))
                .addLayer(Arrays.asList(Paths.get("jars/script.sh")), AbsoluteUnixPath.get("/"))
                .setEntrypoint("sh","/script.sh")
                .containerize(
                        Containerizer.to(TarImage.at(Paths.get("images/"+appName+"-image:latest.tar"))
                                .named(appName+"-image:latest")));
    }

By building a .tar Image then load it to docker via docker load < image_name you can store and run multiple local docker image in containers

N7Legend
  • 71
  • 9