Docker 构建失败 - 退出代码:100 服务 'laravel.test' 构建失败:构建失败

Docker Compose failing build - exit code: 100 Service 'laravel.test' failed to build : Build failed

我在执行 docker-compose up -d 后收到以下错误:

exit code: 100 Service 'laravel.test' failed to build : Build failed

我是 运行 来自 Windows 10 的 Bash 终端。它用于 Laravel PHP 应用程序。

这是我的 docker-compose.yml 文件:

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - pgsql
            - redis
    pgsql:
        image: 'postgres:13'
        ports:
            - '${FORWARD_DB_PORT:-5432}:5432'
        environment:
            PGPASSWORD: '${DB_PASSWORD:-secret}'
            POSTGRES_DB: '${DB_DATABASE}'
            POSTGRES_USER: '${DB_USERNAME}'
            POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
        volumes:
            - 'sailpgsql:/var/lib/postgresql/data'
        networks:
            - sail
        healthcheck:
            test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"]
            retries: 3
            timeout: 5s
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
        healthcheck:
            test: ["CMD", "redis-cli", "ping"]
            retries: 3
            timeout: 5s
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - '${FORWARD_MAILHOG_PORT:-1025}:1025'
            - '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sailpgsql:
        driver: local
    sailredis:
        driver: local

完整错误日志:

$ docker-compose down && docker-compose up -d
Removing network mccoy_sail
Creating network "mccoy_sail" with driver "bridge"
Building laravel.test
#1 [internal] load build definition from Dockerfile
#1 sha256:bb2b701f7101439e80d79e3c322f78f0280baef84167ba1981c4a6f964206e09
#1 transferring dockerfile: 32B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:b9305cedb52486a8251e0de7a8ec22c63301b44f3eec36cb95cfe17d0f576101
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/ubuntu:21.04
#3 sha256:77f2f3e1058c306cdbda7916b1ae303fdb26fc49e385534ae8aa5e1333051bee
#3 DONE 1.7s

#4 [ 1/11] FROM docker.io/library/ubuntu:21.04@sha256:ba394fabd516b39ccf8597ec656a9ddd7d0a2688ed8cb373ca7ac9b6fe67848f
#4 sha256:60b906028ef2f1d7caed619a77694d20e602151bcb693ec66bf809647a067683
#4 DONE 0.0s

#5 [ 2/11] WORKDIR /var/www/html
#5 sha256:064f64b9c63b3d1af598f8543c3b31a5901c756f9a95db9cd9aeaabb21d5327e
#5 CACHED

#6 [ 3/11] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone
#6 sha256:9c8400b64ec11dd0fd35b80486982c4786ae010699f5b92c04054df3a6f9ad55
#6 CACHED

#11 [internal] load build context
#11 sha256:ca8e88d7d9a618d5cfd212f091947fa55c444b4d2b1010519067a572ead8e0ae
#11 transferring context: 99B done
#11 DONE 0.1s

#7 [ 4/11] RUN apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2     && mkdir -p ~/.gnupg     && chmod 600 ~/.gnupg     && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C     && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > 

// 由于演示原因,在 SO 上省略了很多内容。

#7 56.77 Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
#7 56.79 Executing: /tmp/apt-key-gpghome.3M6BNcO2xW/gpg.1.sh --homedir /root/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C
#7 56.89 gpg: key 00A6F0A3C300EE8C: public key "Launchpad Stable" imported
#7 56.89 gpg: Total number processed: 1
#7 56.89 gpg:               imported: 1
#7 57.25 Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu hirsute InRelease [23.9 kB]
#7 57.26 Hit:2 http://security.ubuntu.com/ubuntu hirsute-security InRelease
#7 57.26 Hit:3 http://archive.ubuntu.com/ubuntu hirsute InRelease
#7 57.31 Hit:4 http://archive.ubuntu.com/ubuntu hirsute-updates InRelease
#7 57.34 Hit:5 http://archive.ubuntu.com/ubuntu hirsute-backports InRelease
#7 57.56 Fetched 23.9 kB in 1s (42.3 kB/s)
#7 57.56 Reading package lists...
#7 58.11 Reading package lists...
#7 58.62 Building dependency tree...
#7 58.74 Reading state information...
#7 59.44 E: Unable to locate package php8.0-cli
#7 59.44 E: Couldn't find any package by glob 'php8.0-cli'
#7 59.44 E: Couldn't find any package by regex 'php8.0-cli'
#7 59.44 E: Unable to locate package php8.0-dev
#7 59.44 E: Couldn't find any package by glob 'php8.0-dev'
#7 59.44 E: Couldn't find any package by regex 'php8.0-dev'
#7 59.44 E: Unable to locate package php8.0-pgsql
#7 59.44 E: Couldn't find any package by glob 'php8.0-pgsql'
#7 59.44 E: Couldn't find any package by regex 'php8.0-pgsql'
#7 59.44 E: Unable to locate package php8.0-sqlite3
#7 59.44 E: Couldn't find any package by glob 'php8.0-sqlite3'
#7 59.44 E: Couldn't find any package by regex 'php8.0-sqlite3'
#7 59.44 E: Unable to locate package php8.0-gd
#7 59.44 E: Couldn't find any package by glob 'php8.0-gd'
#7 59.44 E: Couldn't find any package by regex 'php8.0-gd'
#7 59.44 E: Unable to locate package php8.0-curl
#7 59.44 E: Couldn't find any package by glob 'php8.0-curl'
#7 59.44 E: Couldn't find any package by regex 'php8.0-curl'
#7 59.44 E: Unable to locate package php8.0-memcached
#7 59.44 E: Couldn't find any package by glob 'php8.0-memcached'
#7 59.44 E: Couldn't find any package by regex 'php8.0-memcached'
#7 59.44 E: Unable to locate package php8.0-imap
#7 59.44 E: Couldn't find any package by glob 'php8.0-imap'
#7 59.44 E: Couldn't find any package by regex 'php8.0-imap'
#7 59.44 E: Unable to locate package php8.0-mysql
#7 59.44 E: Couldn't find any package by glob 'php8.0-mysql'
#7 59.44 E: Couldn't find any package by regex 'php8.0-mysql'
#7 59.44 E: Unable to locate package php8.0-mbstring
#7 59.44 E: Couldn't find any package by glob 'php8.0-mbstring'
#7 59.44 E: Couldn't find any package by regex 'php8.0-mbstring'
#7 59.44 E: Unable to locate package php8.0-xml
#7 59.44 E: Couldn't find any package by glob 'php8.0-xml'
#7 59.44 E: Couldn't find any package by regex 'php8.0-xml'
#7 59.44 E: Unable to locate package php8.0-zip
#7 59.44 E: Couldn't find any package by glob 'php8.0-zip'
#7 59.44 E: Couldn't find any package by regex 'php8.0-zip'
#7 59.44 E: Unable to locate package php8.0-bcmath
#7 59.44 E: Couldn't find any package by glob 'php8.0-bcmath'
#7 59.44 E: Couldn't find any package by regex 'php8.0-bcmath'
#7 59.44 E: Unable to locate package php8.0-soap
#7 59.44 E: Couldn't find any package by glob 'php8.0-soap'
#7 59.44 E: Couldn't find any package by regex 'php8.0-soap'
#7 59.44 E: Unable to locate package php8.0-intl
#7 59.44 E: Couldn't find any package by glob 'php8.0-intl'
#7 59.44 E: Couldn't find any package by regex 'php8.0-intl'
#7 59.44 E: Unable to locate package php8.0-readline
#7 59.44 E: Couldn't find any package by glob 'php8.0-readline'
#7 59.44 E: Couldn't find any package by regex 'php8.0-readline'
#7 59.44 E: Unable to locate package php8.0-pcov
#7 59.44 E: Couldn't find any package by glob 'php8.0-pcov'
#7 59.44 E: Couldn't find any package by regex 'php8.0-pcov'
#7 59.44 E: Unable to locate package php8.0-msgpack
#7 59.44 E: Couldn't find any package by glob 'php8.0-msgpack'
#7 59.44 E: Couldn't find any package by regex 'php8.0-msgpack'
#7 59.44 E: Unable to locate package php8.0-igbinary
#7 59.44 E: Couldn't find any package by glob 'php8.0-igbinary'
#7 59.44 E: Couldn't find any package by regex 'php8.0-igbinary'
#7 59.44 E: Unable to locate package php8.0-ldap
#7 59.44 E: Couldn't find any package by glob 'php8.0-ldap'
#7 59.44 E: Couldn't find any package by regex 'php8.0-ldap'
#7 59.44 E: Unable to locate package php8.0-redis
#7 59.44 E: Couldn't find any package by glob 'php8.0-redis'
#7 59.44 E: Couldn't find any package by regex 'php8.0-redis'
#7 59.44 E: Unable to locate package php8.0-swoole
#7 59.44 E: Couldn't find any package by glob 'php8.0-swoole'
#7 59.44 E: Couldn't find any package by regex 'php8.0-swoole'
#7 59.44 E: Unable to locate package php8.0-xdebug
#7 59.44 E: Couldn't find any package by glob 'php8.0-xdebug'
#7 59.44 E: Couldn't find any package by regex 'php8.0-xdebug'
#7 ERROR: executor failed running [/bin/sh -c apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2     && mkdir -p ~/.gnupg     && chmod 600 ~/.gnupg     && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C     && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php8.0-cli php8.0-dev        php8.0-pgsql php8.0-sqlite3 php8.0-gd        php8.0-curl php8.0-memcached        php8.0-imap php8.0-mysql php8.0-mbstring        php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap        php8.0-intl php8.0-readline php8.0-pcov        php8.0-msgpack php8.0-igbinary php8.0-ldap        php8.0-redis php8.0-swoole php8.0-xdebug     && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer     && curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -     && apt-get install -y nodejs     && npm install -g npm     && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -     && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*]: exit code: 100
------
 > [ 4/11] RUN apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2     && mkdir -p ~/.gnupg     && chmod 600 ~/.gnupg     && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C     && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php8.0-cli php8.0-dev        php8.0-pgsql php8.0-sqlite3 php8.0-gd        php8.0-curl php8.0-memcached        php8.0-imap php8.0-mysql php8.0-mbstring        php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap        php8.0-intl php8.0-readline php8.0-pcov        php8.0-msgpack php8.0-igbinary php8.0-ldap        php8.0-redis php8.0-swoole php8.0-xdebug     && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer     && curl -sL https://deb.nodesource.com/setup_16.x | bash -     && apt-get install -y nodejs     && npm install -g npm     && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -     && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*:
------
executor failed running [/bin/sh -c apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2     && mkdir -p ~/.gnupg     && chmod 600 ~/.gnupg     && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C     && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C     && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php8.0-cli php8.0-dev        php8.0-pgsql php8.0-sqlite3 php8.0-gd        php8.0-curl php8.0-memcached        php8.0-imap php8.0-mysql php8.0-mbstring        php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap        php8.0-intl php8.0-readline php8.0-pcov        php8.0-msgpack php8.0-igbinary php8.0-ldap        php8.0-redis php8.0-swoole php8.0-xdebug     && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer     && curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -     && apt-get install -y nodejs     && npm install -g npm     && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -     && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*]: exit code: 100
Service 'laravel.test' failed to build : Build failed

原来我必须通过在 docker 容器之外执行 composer update 来更新 Laravel Sail 版本。我在本地安装了 WAMP,因此我能够 运行 作曲家更新。只需确保您的 PHP CLI 版本与 Docker 容器中所需的版本相匹配。