Dockerizing CakePHP,要安装哪些依赖项

I'm a beginner at docker(4 days of studying) and I'm trying to create a CakePHP app inside docker. Tutorials suggest to use the PHP as a base image, but I'm wondering about how they came up with

    RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
        zlib1g-dev \
        libicu-dev \
        g++ \
    && docker-php-ext-configure intl \
    && docker-php-ext-install -j$(nproc) iconv mcrypt intl pdo pdo_mysql mbstring \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

I checked out cakephp 3 documentation and it only says a bunch of things required like: php intl extension mbstring simpleXML PHP Extension etc..

Basically I'm having a hard time figuring out what dependencies to install when building docker images. I was wondering how they knew they needed to install all these libraries like libicu-dev, zlib1g-dev, libpng12-dev. I don't see the https://hub.docker.com/_/php/ nor cakephp installation in the docs mentioning any of these libraries and that they needed to be installed.

I was hoping that there was some sort of docs like "These files such as libicu-dev need to be installed because (insert reason here)".

Reference:

http://blog.danielcorreia.net/practical-docker-apache-php-and-mysql-cakephp-example/ https://book.cakephp.org/3.0/en/installation.html

P.S. I apologize if this is such a beginner's post. Any help is greatly appreciated!