无法在 docker 镜像中找到包

我正在尝试使用 laravel 和 postgres 为应用程序设置 docker 映像,但在尝试安装 postgres 的 php 驱动程序时遇到了困难。


我的 Dockerfile:


FROM php:7.4-fpm


# Arguments defined in docker-compose.yml

ARG user

ARG uid


# Install system dependencies

RUN apt-get update && apt-get install -y \

    git \

    curl \

    libpng-dev \

    libonig-dev \

    libxml2-dev \

    zip \

    unzip \

    postgresql-client \

    libpq-dev \

    php7.4-pgsql


# Clear cache

RUN apt-get clean && rm -rf /var/lib/apt/lists/*


# Install PHP extensions

RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd 


# Get latest Composer

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer


# Create system user to run Composer and Artisan Commands

RUN useradd -G www-data,root -u $uid -d /home/$user $user

RUN mkdir -p /home/$user/.composer && \

    chown -R $user:$user /home/$user


# Set working directory

WORKDIR /var/www


USER $user

我收到的错误:


E: Unable to locate package php7.4-pgsql

E: Couldn't find any package by glob 'php7.4-pgsql'

E: Couldn't find any package by regex 'php7.4-pgsql'

ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y php7.4-pgsql' returned a non-zero code: 100


九州编程
浏览 92回答 1
1回答

www说

它看起来pgsql不包含在 PHP Docker 镜像中。我使用docker-php-extension-installer将所需的扩展添加到我的 Docker 映像中。我将以下两行添加到我的 dockerfile 中,现在一切都按预期工作ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/ RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \     install-php-extensions pdo_pgsql
打开App,查看更多内容
随时随地看视频慕课网APP