Question: I am using the official php docker image as base for my application container, so the Dockerfile starts like so: 

```
FROM php:5.6-fpm-jessie

```

Later in the file I would like to have something like that: 

```
 RUN apt-get update \
    && apt-get install -y libssh2-1-dev libssh2-1 \
    && docker-php-ext-install ssh2

```

But that tells me:

```
/usr/src/php/ext/ssh2 does not exist

```

So since that is a debian (yessie) based image, only the old php5 packages are available and php7 is installed by some tricky script in the [php:fpm dockerfile](https://stackoverflow.com/questions/46805787/docker-phpfpm-install-php-extensions) and it seams that all extensions are compiled within the used php executable.

How can I install more extensions in this scenario?

Answer: 
In case you are using PHP >=8.0 image:

```
FROM php:8.0.2-fpm

RUN apt-get install -y libssh2-1-dev libssh2-1 \
    && pecl install ssh2-1.3.1 \
    && docker-php-ext-enable ssh2

```
I had some error on an other solutions
In my running container on [richarvey/nginx-php-fpm](https://hub.docker.com/r/richarvey/nginx-php-fpm) image worked with two command.

```
apk add --no-cache libssh2-dev autoconf build-base
pecl install https://pecl.php.net/get/ssh2-1.3.tgz
docker-php-ext-enable ssh2

```