<envPropertyFile> not able to add environment variables

I have a maven project where I am using docker-maven-plugin to build docker images. I want to insert environment variables from one environment.properties file. But using the file is not working.

Code is as below:

        <plugins>

            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.31.0</version>
                <configuration>
                    <images>
                        <image>
                            <name>test-image-2</name>
                            <build>
                                <from>
                                    alpine:3.7
                                </from>
                            </build>
                            <run>
                                <envPropertyFile>${basedir}/src/main/docker/environment.properties</envPropertyFile>
                            </run>
                        </image>
                    </images>
                </configuration>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>```

It is a basic dockerfile to be build. I just want to fetch environment variables from an external file.

Source: StackOverflow