Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker php—install php extensions ssh2

Tags:

php

docker

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 and it seams that all extensions are compiled within the used php executable.

How can I install more extensions in this scenario?

like image 611
code.g Avatar asked Nov 30 '22 14:11

code.g


1 Answers

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
like image 84
Mantas Vaitkūnas Avatar answered Dec 03 '22 04:12

Mantas Vaitkūnas