Docker+laravel7.xでrequire laravel/uiでInstallation failed, reverting ./composer.json to its original content.

Dockerのphp:7.3-fpm-alpineで、composer require laravel/uiを入れようとすると「Installation failed, reverting ./composer.json to its original content.」のエラーになる。

$ php composer.phar require laravel/ui:^2.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing laravel/ui (v2.0.1): Downloading (100%)

Installation failed, reverting ./composer.json to its original content.


Warning: proc_open(): fork failed - Out of memory in phar:///var/www/html/composer.phar/vendor/symfony/console/Application.php on line 952

  [ErrorException]
  proc_open(): fork failed - Out of memory

最初、fork failed – Out of memoryのエラーが出ているので、swapメモリを増やしたが、結果は同じ。
$ /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ /sbin/mkswap /var/swap.1
$ /sbin/swapon /var/swap.1

色々調べたがLaravel7.x系は記事が少なく、原因はわからず。とりあえずcomposer.jsonに直接書いてupdateしてみることに。
$ vi composer.json

"require": {
        "php": "^7.2.5",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.0",
        "laravel/tinker": "^2.0",
        "laravel/ui" : "^2.0"
   },
$ php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing laravel/ui (v2.0.1): Downloading (100%)
Writing lock file
Generating optimized autoload files
// 省略

上手くいきました。何故だろう???
Docker上でcomposer requireするときはcomposer.jsonに書かないと駄目なのか?理由が良く解らない。