Skip to content
This repository was archived by the owner on Oct 26, 2019. It is now read-only.
This repository was archived by the owner on Oct 26, 2019. It is now read-only.

"Invalid argument supplied for foreach()" in case container does not have mapped all the ports #308

@Delorien84

Description

@Delorien84

Hi,
when calling Client::containerInspect on container that does not have mapped all ports, I get Invalid argument supplied for foreach() exception in Normalizer/NetworkSettingsNormalizer.php:60.

The $value variable may be null in case the port is not mapped

        if (property_exists($data, 'Ports') && $data->{'Ports'} !== null) {
            $values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
            foreach ($data->{'Ports'} as $key => $value) {
                $values_1 = [];
                foreach ($value as $value_1) {
                    $values_1[] = $this->denormalizer->denormalize($value_1, 'Docker\\API\\Model\\PortBinding', 'json', $context);
                }
                $values[$key] = $values_1;
            }
            $object->setPorts($values);
        }

Fragment of docker inspect command:

               "8302/udp": null,
                "8500/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32792"
                    }
                ],

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions