vimalDev
vimalDev

Reputation: 452

How to pull docker image on remote machine using java?

I want to pull image on remote docker-machine so I found one git repo which will run docker using java.

So I tried using the following way,

  1. First I configured a docker setup
    final DockerClient docker = DefaultDockerClient.builder()
        .uri(URI.create("https://remote ipaddress:port"))
        .dockerCertificates(new DockerCertificates(docker certificate path))
        .build();
  1. host configured
    final HostConfig hostConfig = HostConfig.builder().build();
  1. Pull image
docker.pull("image name");
  1. Creating container with ContainerConfig
final ContainerConfig containerConfig = ContainerConfig.builder()
                        .hostConfig(hostConfig)
                        .image("image name")
                        .cmd("sh", "-c", "while :; do sleep 1; done")
                        .build();
  1. Deploying docker container at remote location
final ContainerCreation creation = docker.createContainer(containerConfig);
                    final String id = creation.id();
  1. Start container
docker.startContainer(id);

After following all the step I am not able to pull image on remote docker configuration pc.

So as a conclusion I want to run docker from the current machine to provided remote docker configuration using java. If you have any idea how can I achieve please let me know.

Upvotes: 1

Views: 718

Answers (0)

Related Questions