Docker无法找到软件包RUN

edqdpe6u  于 2023-04-20  发布在  Docker
关注(0)|答案(1)|浏览(225)

我有一个docker镜像,在另一个使用相同docker镜像的服务器上运行完美,没有任何问题,一切都完全相同。
现在我尝试复制相同的图像到新的服务器,当我尝试安装它,我面对这个错误
我正在尝试运行docker php image,并在下面得到此错误

0.0s
 => ERROR [ 2/14] RUN apt-get update && apt-get install -y --no-install-recommends   autoconf   build-essential   apt-utils   zlib1g-dev   libzip-dev   unzip   zip   libmagick++-dev   libmagickwand-dev   libpq-dev   libfreetype6-dev   l  4.4s
------                                                                                                                                                                                                                                             
 > [ 2/14] RUN apt-get update && apt-get install -y --no-install-recommends   autoconf   build-essential   apt-utils   zlib1g-dev   libzip-dev   unzip   zip   libmagick++-dev   libmagickwand-dev   libpq-dev   libfreetype6-dev   libjpeg62-turbo-dev   libpng-dev RUN docker-php-ext-install gd intl pdo_mysql pdo_pgsql mysqli zip:                                                                                                                                                               
#0 0.377 Get:1 http://security.debian.org/debian-security bullseye-security InRelease [48.4 kB]                                                                                                                                                    
#0 0.377 Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]                                                                                                                                                                            
#0 0.387 Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]                                                                                                                                                                   
#0 0.493 Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [222 kB]
#0 0.619 Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
#0 0.757 Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [14.6 kB]
#0 1.937 Fetched 8628 kB in 2s (5482 kB/s)
#0 1.937 Reading package lists...
#0 2.676 Reading package lists...
#0 3.481 Building dependency tree...
#0 3.690 Reading state information...
#0 3.900 E: Unable to locate package RUN
#0 3.900 E: Unable to locate package docker-php-ext-install
#0 3.900 E: Unable to locate package gd
#0 3.900 E: Unable to locate package intl
#0 3.900 E: Unable to locate package pdo_mysql
#0 3.900 E: Unable to locate package pdo_pgsql
#0 3.900 E: Unable to locate package mysqli
------
failed to solve: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends   autoconf   build-essential   apt-utils   zlib1g-dev   libzip-dev   unzip   zip   libmagick++-dev   libmagickwand-dev   libpq-dev   libfreetype6-dev   libjpeg62-turbo-dev   libpng-dev RUN docker-php-ext-install gd intl pdo_mysql pdo_pgsql mysqli zip" did not complete successfully: exit code: 100

Dockerfile

FROM php:7.4.29-apache

RUN apt-get update && apt-get install -y --no-install-recommends \
  autoconf \
  build-essential \
  apt-utils \
  zlib1g-dev \
  libzip-dev \
  unzip \
  zip \
  libmagick++-dev \
  libmagickwand-dev \
  libpq-dev \
  libfreetype6-dev \
  libjpeg62-turbo-dev \
  libpng-dev \
  sendmail

RUN docker-php-ext-install gd intl pdo_mysql pdo_pgsql mysqli zip

RUN pecl install imagick-3.4.3

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

RUN docker-php-ext-enable imagick

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN echo "sendmail_path=/usr/sbin/sendmail -t -i" >> /usr/local/etc/php/conf.d/sendmail.ini 

RUN sed -i '/#!\/bin\/sh/aservice sendmail restart' /usr/local/bin/docker-php-entrypoint

# Clear package lists
RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

# Permissions
RUN chown -R root:www-data /var/www/html
RUN chmod u+rwx,g+rx,o+rx /var/www/html
RUN find /var/www/html -type d -exec chmod u+rwx,g+rx,o+rx {} +
RUN find /var/www/html -type f -exec chmod u+rw,g+rw,o+r {} +

WORKDIR /var/www/html

RUN a2enmod rewrite
RUN a2enmod ssl

EXPOSE 80
EXPOSE 443

docker-compose.yml文件

version: '3.8'
services:
  WebApp:
    container_name: "apache-server"
    build: 
       context: .docker/php
       dockerfile: Dockerfile
    image: server-apache
    volumes:
      - .docker/apache/server.pem:/etc/ssl/certs/server.pem
      - .docker/apache/server-key.pem:/etc/ssl/private/server-key.pem
      - .docker/apache/000-default.conf:/etc/apache2/sites-enabled/000-default.conf
      - ./src:/var/www/html
    ports:
      - 80:80
      - 443:443
    restart: always
    
  database:
    container_name: database
    image: mysql
    volumes:
      - .docker/db:/var/lib/mysql
    ports:
      - "9906:3306"
    environment:
      MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD
      MYSQL_DATABASE: MYSQL_DATABASE
      MYSQL_USER: MYSQL_USER
      MYSQL_PASSWORD: MYSQL_PASSWORD
    restart: always

  phpmyadmin:
        container_name: PhpMyAdmin
        image: phpmyadmin/phpmyadmin
        ports:
            - '8080:80'
        restart: always
        environment:
            PMA_HOST: database
            UPLOAD_LIMIT: 128M
        depends_on:
            - database
  
volumes:
  databaseData:
    external: false

我试着改变php版本到最新仍然得到相同的错误
我试着在网上查找错误,我没有找到这样的错误
-------UPDATE-----旧服务器上的docker版本为20.10.7新服务器上的docker版本为:23.0.0

2nc8po8w

2nc8po8w1#

请检查https://github.com/mlocati/docker-php-extension-installer
您需要添加到Dockerfile

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod +x /usr/local/bin/install-php-extensions

RUN docker-php-ext-install ...

相关问题