private void mapHostPortToSpec(String hPort, String portSpec) {
        Integer hostPort;
        if (hPort == null) {
            hostPort = null;
        } else {
            try {
                hostPort = Integer.parseInt(hPort);
            } catch (@SuppressWarnings("unused") NumberFormatException exp) {
                // Port should be dynamically assigned and set to the variable give in hPort
                String portPropertyName = extractPortPropertyName(hPort);

                hostPort = getPortFromProjectOrSystemProperty(portPropertyName);
                if (hostPort != null) {
                    // portPropertyName: Prop name, hostPort: Port from a property value (prefilled)
                    hostPortVariableMap.put(portPropertyName, hostPort);
                } else {
                    // portSpec: Port from container, portPropertyName: Variable name to be filled in later
                    specToHostPortVariableMap.put(portSpec, portPropertyName);
                }
            }
        }
        containerPortToHostPort.put(portSpec, hostPort);
    }
Return the content of the mapping as an array with all specifications as given

@return port mappings as JSON array or null if no mappings exist
src/main/java/io/fabric8/maven/docker/access/PortMapping.java