Error with matrix and docker image

I would like to tag my docker image with second tag (php minor version).

stage("Build") {
            matrix {
                 agent {
                     docker {
                         image "php:${PHP_VERSION}-fpm"
                     }
                 }

                axes {
                    axis {
                        name "PHP_VERSION"
                        values "8.0", "8.1", "8.2"
                    }
                }

                stages {
                    stage('Check version php:${PHP_VERSION}-fpm') {
                        steps {
                            script {
                                php80php = sh (
                                script: "php -r 'echo PHP_VERSION;'",
                                returnStdout: true
                                ).trim()
                                echo "${phpminorversion}"
                            }
                        }
                    }

                    stage("Build image") {
                         steps {
                            sh """
                                docker buildx build --target php-fpm --build-arg PHP_TYPE=fpm --build-arg PHP_VERSION=${PHP_VERSION} --push --platform linux/amd64,linux/arm64 -t my_image/php-fpm:${PHP_VERSION} -t droptica/php-fpm:${phpminorversion} --no-cache .
                        """
                        }
                    }

                    stage('php version') {
                        agent {
                            docker { image "my_image/php-fpm:${PHP_VERSION}" }
                            }
                        steps {
                            script {
                                sh 'php -version'
                            }
                        }
                    }
                }
            }
        }
    }

The matrix seems to be working:

Screenshot from 2023-06-29 10-49-58

But in stage Build image something is wrong. Firstly, it substitutes version 8.2.7 for each major PHP version, secondly, line 2 error: docker: not found

Hello @wojtek and welcome to this community. :wave:

Is docker installed in the image used by your docker agent?