private List<Container> getContainersForImage(QueryService queryService, ImageConfiguration imageConfiguration)
            throws IOException, MojoExecutionException {
        String imageName = imageConfiguration.getName();
        String copyNamePattern = imageConfiguration.getCopyNamePattern();
        Matcher containerNameMatcher =
                copyNamePattern == null ? null : getContainerNameMatcher(copyNamePattern, COPY_NAME_PATTERN_CONFIG);
        if (copyAll) {
            if (containerNameMatcher == null) {
                return queryService.getContainersForImage(imageName, true);
            }
            return getContainersForPattern(queryService, true, null, containerNameMatcher, COPY_NAME_PATTERN_CONFIG);
        }
        Container latestContainer;
        if (containerNameMatcher == null) {
            latestContainer = queryService.getLatestContainerForImage(imageName, true);
        } else {
            List<Container> matchingContainers = getContainersForPattern(queryService, true, null, containerNameMatcher,
                    COPY_NAME_PATTERN_CONFIG);
            latestContainer = queryService.getLatestContainer(matchingContainers);
        }
        return latestContainer == null ? Collections.emptyList() : Collections.singletonList(latestContainer);
    }
Whether to copy from all containers matching configured images or only from the newest ones.
src/main/java/io/fabric8/maven/docker/CopyMojo.java