@SneakyThrows
    default <T> T copyFileFromContainer(String containerPath, ThrowingFunction<InputStream, T> function) {
        if (getContainerId() == null) {
            throw new IllegalStateException("copyFileFromContainer can only be used when the Container is created.");
        }

        DockerClient dockerClient = getDockerClient();
        try (
            InputStream inputStream = dockerClient.copyArchiveFromContainerCmd(getContainerId(), containerPath).exec();
            TarArchiveInputStream tarInputStream = new TarArchiveInputStream(inputStream)
        ) {
            tarInputStream.getNextTarEntry();
            return function.apply(tarInputStream);
        }
    }
Streams a file which resides inside the container

@param containerPath path to file which is copied from container
@param function function that takes InputStream of the copied file
core/src/main/java/org/testcontainers/containers/ContainerState.java