Fatal error: Uncaught Error: Call to undefined function CommonMark\Parse()

First of all

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

$ docker-compose -v
docker-compose version 1.29.2, build unknown

Let’s get to the point

$ docker run php -r 'CommonMark\Parse();'
Fatal error: Uncaught Error: Call to undefined function CommonMark\Parse() in Command line code:1

Maybe some extension is missing?
From what I see from the page PHP: CommonMark\Parse - Manual I think it should be the cmark extension.
Let’s do another test…

$ cat docker-compose.yml 
services:
    php:
        build: .

$ cat Dockerfile 
FROM php
RUN docker-php-ext-install cmark

$ docker-compose run php -r 'CommonMark\Parse();'
Building php
Step 1/2 : FROM php
 ---> 2d9f89fee2cf
Step 2/2 : RUN docker-php-ext-install cmark
 ---> Running in cd76a3406bd1
error: /usr/src/php/ext/cmark does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] [--ini-name file.ini] ext-name [ext-name ...]
   ie: /usr/local/bin/docker-php-ext-install gd mysqli
       /usr/local/bin/docker-php-ext-install pdo pdo_mysql
       /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dl_test dom enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv imap intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer xml xmlreader xmlwriter xsl zend_test zip

Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Service 'php' failed to build : The command '/bin/sh -c docker-php-ext-install cmark' returned a non-zero code: 1

error: /usr/src/php/ext/cmark does not exist
How can I solve?