private void waitUntilReady() throws InterruptedException, MalformedURLException {
    URL queryUrl = new URL("http://" + dockerHost + ":" + port + "/v2/_catalog");

    for (int i = 0; i < 40; i++) {
      try {
        HttpURLConnection connection = (HttpURLConnection) queryUrl.openConnection();
        int code = connection.getResponseCode();
        if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_UNAUTHORIZED) {
          return;
        }
      } catch (IOException ex) {
        // ignored
      }
      Thread.sleep(250);
    }
  }
Pulls an image and pushes it to the local registry under a new tag.

@param from the image reference to pull
@param to the new location of the image (i.e. {@code localhost:[port]/[to]}
@throws IOException if the commands fail
@throws InterruptedException if the commands are interrupted
jib-core/src/integration-test/java/com/google/cloud/tools/jib/registry/LocalRegistry.java