private Runnable createCopyWatchTask(final ImageWatcher watcher,
                                         final String assemblyName,
                                         final MojoParameters mojoParameters, final String containerBaseDir) throws MojoExecutionException {
        final ImageConfiguration imageConfig = watcher.getImageConfiguration();

        final AssemblyFiles files = archiveService.getAssemblyFiles(imageConfig, assemblyName, mojoParameters);
        return () -> {
            List<AssemblyFiles.Entry> entries = files.getUpdatedEntriesAndRefresh();
            if (entries != null && !entries.isEmpty()) {
                try {
                    log.info("%s: Assembly %s changed. Copying changed files to container ...", imageConfig.getDescription(), assemblyName);

                    File changedFilesArchive = archiveService.createChangedFilesArchive(entries, files.getAssemblyDirectory(),
                            imageConfig.getName(), mojoParameters);
                    dockerAccess.copyArchiveToContainer(watcher.getContainerId(), changedFilesArchive, containerBaseDir);
                    callPostExec(watcher);
                } catch (MojoExecutionException | IOException | ExecException e) {
                    log.error("%s: Error when copying files to container %s: %s",
                              imageConfig.getDescription(), watcher.getContainerId(), e.getMessage());
                }
            }
        };
    }
Watch service for monitoring changes and restarting containers
src/main/java/io/fabric8/maven/docker/service/WatchService.java