public void pullImage ( DockerImagePullStrategy pullStrategy , String imageName ) throws InterruptedException { LOG . info ( "Pulling image {} with {} strategy..." , imageName , pullStrategy ) ; final List < Image > images = getDockerCli ( ) . listImagesCmd ( ) . withShowAll ( true ) . exec ( ) ; NameParser . ReposTag repostag = NameParser . parseRepositoryTag ( imageName ) ; // if image was specified without tag, then treat as latest final String fullImageName = repostag . repos + ":" + ( repostag . tag . isEmpty ( ) ? "latest" : repostag . tag ) ; boolean hasImage = Iterables . any ( images , image -> nonNull ( image . getRepoTags ( ) ) && Arrays . asList ( image . getRepoTags ( ) ) . contains ( fullImageName ) ) ; boolean pull = hasImage ? pullStrategy . pullIfExists ( imageName ) : pullStrategy . pullIfNotExists ( imageName ) ; if ( pull ) { LOG . info ( "Pulling image '{}' {}. This may take awhile..." , imageName , hasImage ? "again" : "since one was not found" ) ; long startTime = System . currentTimeMillis ( ) ; //Identifier amiId = Identifier.fromCompoundString(ami); getDockerCli ( ) . pullImageCmd ( imageName ) . exec ( new PullImageResultCallback ( ) ) . awaitSuccess ( ) ; long pullTime = System . currentTimeMillis ( ) - startTime ; LOG . info ( "Finished pulling image '{}', took {} ms" , imageName , pullTime ) ; } }
Pull docker image on this docker host .