@Test @Ignore("Need a running Docker daemon") public void testPullImage() throws Exception { dockerClient.pull("mkroli/karaf", "latest", true); }
public void pull(String name, String tag, boolean verbose) throws Exception { URL dockerUrl = new URL(this.url + "/images/create?fromImage=" + name + "&tag=" + tag); HttpURLConnection connection = (HttpURLConnection) dockerUrl.openConnection(); connection.setRequestMethod("POST"); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = reader.readLine()) != null) { LOGGER.debug(line); if (verbose) { System.out.println(line); } } if (connection.getResponseCode() != 200) { throw new IllegalStateException("Can't pull image " + name + ": " + connection.getResponseMessage()); } }
DockerClient { public void pull(String name, String tag, boolean verbose) throws Exception { URL dockerUrl = new URL(this.url + "/images/create?fromImage=" + name + "&tag=" + tag); HttpURLConnection connection = (HttpURLConnection) dockerUrl.openConnection(); connection.setRequestMethod("POST"); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = reader.readLine()) != null) { LOGGER.debug(line); if (verbose) { System.out.println(line); } } if (connection.getResponseCode() != 200) { throw new IllegalStateException("Can't pull image " + name + ": " + connection.getResponseMessage()); } } }
DockerClient { public void pull(String name, String tag, boolean verbose) throws Exception { URL dockerUrl = new URL(this.url + "/images/create?fromImage=" + name + "&tag=" + tag); HttpURLConnection connection = (HttpURLConnection) dockerUrl.openConnection(); connection.setRequestMethod("POST"); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = reader.readLine()) != null) { LOGGER.debug(line); if (verbose) { System.out.println(line); } } if (connection.getResponseCode() != 200) { throw new IllegalStateException("Can't pull image " + name + ": " + connection.getResponseMessage()); } } DockerClient(String url); }
DockerClient { public void pull(String name, String tag, boolean verbose) throws Exception { URL dockerUrl = new URL(this.url + "/images/create?fromImage=" + name + "&tag=" + tag); HttpURLConnection connection = (HttpURLConnection) dockerUrl.openConnection(); connection.setRequestMethod("POST"); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = reader.readLine()) != null) { LOGGER.debug(line); if (verbose) { System.out.println(line); } } if (connection.getResponseCode() != 200) { throw new IllegalStateException("Can't pull image " + name + ": " + connection.getResponseMessage()); } } DockerClient(String url); Info info(); Version version(); List<Container> ps(boolean showAll); Container inspect(String id); Top top(String id); void create(ContainerConfig config, String name); void rm(String id, boolean removeVolumes, boolean force); void start(String id); void stop(String id, int timeToWait); void restart(String id, int timeToWait); void kill(String id, String signal); void rename(String id, String name); void pause(String id); void unpause(String id); String logs(String id, boolean stdout, boolean stderr, boolean timestamps, boolean details); void commit(String container, ContainerConfig config, String message, String repo, String tag); List<Image> images(boolean showAll); void pull(String name, String tag, boolean verbose); void push(String name, String tag, boolean verbose); void tag(String name, String repo, String tag); void rmi(String name, boolean force, boolean noprune); List<ImageSearch> search(String term); Image getImage(String name); List<ImageHistory> history(String name); }
DockerClient { public void pull(String name, String tag, boolean verbose) throws Exception { URL dockerUrl = new URL(this.url + "/images/create?fromImage=" + name + "&tag=" + tag); HttpURLConnection connection = (HttpURLConnection) dockerUrl.openConnection(); connection.setRequestMethod("POST"); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while ((line = reader.readLine()) != null) { LOGGER.debug(line); if (verbose) { System.out.println(line); } } if (connection.getResponseCode() != 200) { throw new IllegalStateException("Can't pull image " + name + ": " + connection.getResponseMessage()); } } DockerClient(String url); Info info(); Version version(); List<Container> ps(boolean showAll); Container inspect(String id); Top top(String id); void create(ContainerConfig config, String name); void rm(String id, boolean removeVolumes, boolean force); void start(String id); void stop(String id, int timeToWait); void restart(String id, int timeToWait); void kill(String id, String signal); void rename(String id, String name); void pause(String id); void unpause(String id); String logs(String id, boolean stdout, boolean stderr, boolean timestamps, boolean details); void commit(String container, ContainerConfig config, String message, String repo, String tag); List<Image> images(boolean showAll); void pull(String name, String tag, boolean verbose); void push(String name, String tag, boolean verbose); void tag(String name, String repo, String tag); void rmi(String name, boolean force, boolean noprune); List<ImageSearch> search(String term); Image getImage(String name); List<ImageHistory> history(String name); static final String DEFAULT_URL; }