public String buildImage ( byte [ ] tarArchive , Optional < String > name , Optional < String > buildArguments ) { Response response = getServiceEndPoint ( ) . path ( "/build" ) . queryParam ( "q" , true ) . queryParam ( "t" , name . orElse ( null ) ) . queryParam ( "buildargs" , UriComponent . encode ( buildArguments . orElse ( null ) , UriComponent . Type . QUERY_PARAM_SPACE_ENCODED ) ) . queryParam ( "forcerm" ) . request ( MediaType . APPLICATION_JSON_TYPE ) . header ( REGISTRY_AUTH_HEADER , getRegistryAuthHeaderValue ( ) ) . post ( Entity . entity ( tarArchive , "application/tar" ) ) ; InputStream inputStream = ( InputStream ) response . getEntity ( ) ; String imageId = parseSteamForImageId ( inputStream ) ; if ( imageId == null ) { throw new DockerException ( "Can't obtain ID from build output stream." ) ; } return imageId ; }
Builds an image based on the passed tar archive . Optionally names &amp ; tags the image