Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install PHP7.4 on stock Alpine 3.12 Docker image?

Is it possible to install PHP7.4 on stock Alpine 3.12 Docker image?

I have seen this repo and its dockerfile which is using bintray cert and repository path, but I was wondering if there is a more "standard/Alpine" way of doing this natively?

like image 811
Norgul Avatar asked Jul 10 '20 14:07

Norgul


2 Answers

You can use below Docker image.

FROM alpine:3.12
RUN apk add --no-cache  --repository http://dl-cdn.alpinelinux.org/alpine/edge/community php
RUN php -v

output

Step 3/3 : RUN php -v
 ---> Running in 9900e66f4b71
PHP 7.4.7 (cli) (built: Jun 14 2020 23:46:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

like image 60
Adiii Avatar answered Sep 29 '22 06:09

Adiii


If you want to see a full fledged example it's always best to investigate the vendor's Dockerfile.

This is from image php:7.4-fpm-alpine3.12:

https://github.com/docker-library/php/blob/86c8ec4d387132b65dbe6c5ab1747f858e03852e/7.4/alpine3.12/fpm/Dockerfile

As you can see, they add a lot of stuff to ensure PHP runs smooth and startup / context problems are solved.

like image 28
Daniel W. Avatar answered Sep 29 '22 08:09

Daniel W.