public static void copyToContainer(
            JibContainerBuilder containerBuilder, File directory, String targetDir, Map<File, AssemblyFiles.Entry> files)
            throws IOException {

        Files.walkFileTree(directory.toPath(), new FileVisitor<Path>() {
            boolean notParentDir = false;

            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {

                if (!notParentDir) {
                    notParentDir = true;
                    return FileVisitResult.CONTINUE;
                }

                String fileFullpath = dir.toAbsolutePath().toString();
                String relativePath = fileFullpath.substring(targetDir.length());
                AbsoluteUnixPath absoluteUnixPath = AbsoluteUnixPath.fromPath(Paths.get(relativePath));
                containerBuilder.addFileEntriesLayer(FileEntriesLayer.builder()
                        .addEntryRecursive(dir, absoluteUnixPath)
                        .build());
                return FileVisitResult.SKIP_SUBTREE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                String fileFullpath = file.toAbsolutePath().toString();
                String relativePath = fileFullpath.substring(targetDir.length());
                AbsoluteUnixPath absoluteUnixPath = AbsoluteUnixPath.fromPath(Paths.get(relativePath));
                containerBuilder.addFileEntriesLayer(FileEntriesLayer.builder()
                        .addEntryRecursive(file, absoluteUnixPath/*, filePermissionsProvider*/)
                        .build());
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                if (exc != null) {
                    throw new IOException(exc);
                }
                return FileVisitResult.TERMINATE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                if (exc != null) {
                    throw new IOException(exc);
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }
Push Image to registry using JIB

@param imageConfiguration ImageConfiguration
@param pushCredentials    push credentials
@param tarArchive         tar archive built during build goal
@param log                Logger
src/main/java/io/fabric8/maven/docker/util/JibServiceUtil.java