[Solved] Error during composer operation in docker: insufficient memory

Background
Need to perform composer removal package operation on lumen framework.
Error message

docker composer remove Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 byt

Solution:

/usr/local/bin/php -d memory_limit=-1 /usr/local/sbin/composer remove xxx

Explanation: php -d memory_limit=-1 means that the php process uses unlimited memory.
Note that both php and composer need to use absolute paths.

Read More: