private void parseAndValidate() {
        final Map<String, ?> servicesMap;
        if (composeFileContent.containsKey("version") && "2.0".equals(composeFileContent.get("version"))) {
            log.warn(
                "Testcontainers may not be able to clean up networks spawned using Docker Compose v2.0 files. " +
                "Please see https://github.com/testcontainers/moby-ryuk/issues/2, and specify 'version: \"2.1\"' or " +
                "higher in {}",
                composeFileName
            );
        }

        if (composeFileContent.containsKey("services")) {
            final Object servicesElement = composeFileContent.get("services");
            if (servicesElement == null) {
                log.debug(
                    "Compose file {} has an unknown format: 'version' is set but 'services' is not defined",
                    composeFileName
                );
                return;
            }
            if (!(servicesElement instanceof Map)) {
                log.debug("Compose file {} has an unknown format: 'services' is not Map", composeFileName);
                return;
            }

            @SuppressWarnings("unchecked")
            Map<String, ?> temp = (Map<String, ?>) servicesElement;
            servicesMap = temp;
        } else {
            servicesMap = composeFileContent;
        }

        for (Map.Entry<String, ?> entry : servicesMap.entrySet()) {
            String serviceName = entry.getKey();
            Object serviceDefinition = entry.getValue();
            if (!(serviceDefinition instanceof Map)) {
                log.debug(
                    "Compose file {} has an unknown format: service '{}' is not Map",
                    composeFileName,
                    serviceName
                );
                break;
            }

            @SuppressWarnings("unchecked")
            final Map<String, ?> serviceDefinitionMap = (Map<String, ?>) serviceDefinition;

            validateNoContainerNameSpecified(serviceName, serviceDefinitionMap);
            findServiceImageName(serviceName, serviceDefinitionMap);
            findImageNamesInDockerfile(serviceName, serviceDefinitionMap);
        }
    }
Representation of a docker-compose file, with partial parsing for validation and extraction of a minimal set of
data.
core/src/main/java/org/testcontainers/containers/ParsedDockerComposeFile.java