php: pecl install redis on php8 fails

2021-01-22 Update:

As highlighted here updating docker for mac to at least 3.1 will resolve this.

Issue appears to be to do with alpine rather than this repo.


Update:

php:8-fpm-alpine fails php:8-fpm-alpine3.12 works


tl;dr I want to pecl install redis on php:8-fpm-alpine.

When trying to build FROM php:8-fpm-alpine with a standard pecl install redis I get this:

No releases available for package "pecl.php.net/redis"
install failed

It looks like install-php-extensions redis even fails, looks like DNS issue:

### INSTALLING REMOTE MODULE redis ###
  - Installing redis (latest-stable): Downloading (failed)
Downloading (failed)
Downloading (failed)
In RemoteFilesystem.php line 560:

  The "https://pecl.php.net/get/redis" file could not be downloaded: php_netw
  ork_getaddresses: getaddrinfo failed: Name does not resolve
  Failed to open stream: php_network_getaddresses: getaddrinfo failed: Name d
  oes not resolve

It’s very possible my issue is ipv6 related, after removing redis from being installed on my docker file and running ping inside the php container:

/var/www/html # ping pecl.php.net
ping: bad address 'pecl.php.net'

forced ipv4 ping:

/var/www/html # ping pecl.php.net -4
PING pecl.php.net (104.236.228.160): 56 data bytes
64 bytes from 104.236.228.160: seq=0 ttl=37 time=108.274 ms
64 bytes from 104.236.228.160: seq=1 ttl=37 time=96.366 ms
^C
--- pecl.php.net ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 96.366/102.320/108.274 ms

forced ipv6 ping:

/var/www/html # ping pecl.php.net -6
ping: bad address 'pecl.php.net'

Is this because there is no ipv6 record on the domain, or, maybe something wrong with my docker-compose.yml or Dockerfile?

version: "3.8"
services:
    php-fpm:
      build:
        context: ./
        dockerfile: ./docker/development/config/php-fpm.dockerfile
      volumes:
        - ./:/var/www/site
      networks:
        - app
    nginx:
      build:
        context: ./
        dockerfile: ./docker/development/config/nginx.dockerfile
      networks:
        - app
volumes:
  mysqldata:
networks:
  app:
    driver: bridge

php-fpm.dockerfile:

ARG PHP_VERSION="8"
ARG PROJECT_TYPE
FROM php:${PHP_VERSION}-fpm-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN pecl install redis

CMD [ "php-fpm" ]

Change: Cut out most of my RUN value in the dockerfile which is not relevant to the issue

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Had the same issue and found this https://github.com/docker/for-mac/issues/5020 - updating Docker for Mac to 3.1.0 fixed the problem for me.

@joepagan you’re right, my comment was totally unrelated, sorry for wasting your time. pecl and pear commands are being deprecated in php8 apparently anyway. This works on php8 (includes your --ipv4 fix), just tried it:

ARG PHP_VERSION="8.0"
ARG ALPINE_VERSION="3.13"
FROM php:${PHP_VERSION}-alpine${ALPINE_VERSION}

RUN mkdir -p /usr/src/php/ext/redis; \
	curl -fsSL https://pecl.php.net/get/redis --ipv4 | tar xvz -C "/usr/src/php/ext/redis" --strip 1; \
	docker-php-ext-install redis;