在Docker中安装pecl时出现“No releases available”错误

uxhixvfz  于 2023-04-05  发布在  Docker
关注(0)|答案(2)|浏览(500)

我试图从pecl在Docker容器中安装Xdebug或Redis包。安装失败并返回错误:
包“www.example.com”没有可用的版本pecl.php.net/xdebug。
Xdebug示例:https://pecl.php.net/package/xdebug/3.1.0
我的docker-compose.yaml

version: '3'

networks:
  app-network:

services:
  site:
    build:
      context: .
      dockerfile: nginx.dockerfile
    container_name: my_nginx
    ports:
      - "8082:80"
      - "443:443"
    volumes:
      - ./src:/var/www/html
    depends_on:
      - php
      - db
      - redis
    networks:
      - app-network

  db:
    image: percona
    container_name: my_db
    restart: on-failure
    tty: true
    ports:
      - "3314:3306"
    volumes:
      - ./percona:/var/lib/percona
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_USER: me
      MYSQL_PASSWORD: 123
      MYSQL_ROOT_PASSWORD: 456
      SERVICE_TAGS: dev
      SERVICE_NAME: db
    networks:
      - app-network

  php:
    build:
      context: .
      dockerfile: php.dockerfile
    container_name: my_php
    volumes:
      - ./src:/var/www/html
    ports:
      - "9000:9000"
    networks:
      - app-network

  composer:
    image: frojd/composer-php-7.4
    container_name: my_composer
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - php
    networks:
      - app-network

  redis:
    image: redis:alpine
    container_name: my_redis
    volumes:
      - ./redis:/data
    restart: on-failure
    command: redis-server --appendonly yes --requirepass "${REDIS_PASSWORD}"
    ports:
      - 6380:6379
    networks:
      - app-network

  npm:
    image: node:14.18.0
    container_name: my_npm
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    entrypoint: ['npm']

  artisan:
    build:
      context: .
      dockerfile: php.dockerfile
    container_name: my_artisan
    volumes:
      - ./src:/var/www/html
    depends_on:
      - db
    working_dir: /var/www/html
    entrypoint: ['php', '/var/www/html/artisan']
    networks:
      - app-network

  cron:
    build:
      context: .
      dockerfile: cron.dockerfile
    container_name: my_cron
    volumes:
      - ./src:/var/www/html
    networks:
      - app-network

我的php.dockerfile

FROM php:7.4-fpm

WORKDIR /var/www/html

RUN apt-get update && \
    apt-get install ca-certificates && \
    apt-get clean

RUN docker-php-ext-install pdo pdo_mysql

RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

错误的原因是什么,我如何修复它?

hs1ihplo

hs1ihplo1#

我通过专门为PECL设置代理来解决这个问题(单独的环境变量$HTTP_PROXY是不起作用的)。

RUN pear config-set http_proxy ${http_proxy} &&\
    pear config-set php_ini $PHP_INI_DIR/php.ini

RUN pecl install xdebug-3.1.1 && docker-php-ext-enable xdebug

这个回答帮助了我:https://stackoverflow.com/a/11195778/256762.希望我的也有帮助😉。

a0zr77ik

a0zr77ik2#

我遇到了类似的问题,不得不更换安装xdebug的方式
之前:

RUN pecl install xdebug-2.9.2 && docker-php-ext-enable xdebug

之后:

RUN cd /tmp && \
    git clone https://github.com/xdebug/xdebug.git && \
    cd xdebug && \
    git checkout xdebug_2_9 && \
    phpize && \
    ./configure --enable-xdebug && \
    make && \
    make install && \
    rm -rf /tmp/xdebug
RUN docker-php-ext-enable xdebug

相关问题