Laravel Sail在第一次执行up安装构建laravel.test的时候出现报错

OS: windows 10
Docker Desktop: 3.5.1(66090)
wsl2: Ubuntu 20.04 LTS

我是按照《搭建 Laravel Sail 开发环境 - Windows》文档,通过curl -s https://laravel.build/example-app | bash命令创建
执行./vendor/bin/sail up进行第一次构建,在Building laravel.test时报错了,我用的是7.4,8.0也执行过都是一样的报错
另外有魔(ke)法(xue)上网,应该不是网络问题,用的是清华大学的镜像

报错信息如下:

Building laravel.test
[+] Building 69.9s (9/16)
 => [internal] load build definition from Dockerfile                                                               1.0s
 => => transferring dockerfile: 32B                                                                                0.1s
 => [internal] load .dockerignore                                                                                  1.3s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/ubuntu:21.04                                                   33.2s
 => [ 1/12] FROM docker.io/library/ubuntu:21.04@sha256:a30456233740024b9d297f5bcaa7439446a97bc59b25cadcdae829c334  0.0s
 => [internal] load build context                                                                                  0.4s
 => => transferring context: 1.03kB                                                                                0.0s
 => CACHED [ 2/12] WORKDIR /var/www/html                                                                           0.0s
 => CACHED [ 3/12] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone                  0.0s
 => [ 4/12] ADD sources.list /etc/apt/                                                                             1.0s
 => ERROR [ 5/12] RUN apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git sup  33.5s
------
 > [ 5/12] 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 https://launchpad.proxy.ustclug.org/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php7.4-cli php7.4-dev        php7.4-pgsql php7.4-sqlite3 php7.4-gd        php7.4-curl php7.4-memcached        php7.4-imap php7.4-mysql php7.4-mbstring        php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap        php7.4-intl php7.4-readline php7.4-pcov        php7.4-msgpack php7.4-igbinary php7.4-ldap        php7.4-redis     && curl -so /usr/bin/composer https://mirrors.aliyun.com/composer/composer.phar     && chmod a+x /usr/bin/composer     && composer --version     && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/     && curl -sL https://deb.nodesource.com/setup_16.x | bash -     && apt-get install -y nodejs     && 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/*:
#9 1.801 Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease [265 kB]
#9 2.739 Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease [114 kB]
#9 3.060 Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease [101 kB]
#9 3.500 Get:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease [114 kB]
#9 3.949 Get:5 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/multiverse amd64 Packages [177 kB]
#9 4.258 Get:6 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/main amd64 Packages [1275 kB]
#9 6.923 Get:7 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/restricted amd64 Packages [33.4 kB]
#9 6.934 Get:8 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/universe amd64 Packages [11.3 MB]
#9 25.82 Get:9 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/restricted amd64 Packages [416 kB]
#9 25.95 Get:10 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/main amd64 Packages [1367 kB]
#9 26.72 Get:11 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/multiverse amd64 Packages [32.0 kB]
#9 26.72 Get:12 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/universe amd64 Packages [1051 kB]
#9 27.06 Get:13 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports/main amd64 Packages [2668 B]
#9 27.07 Get:14 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports/universe amd64 Packages [6315 B]
#9 27.07 Get:15 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/restricted amd64 Packages [368 kB]
#9 27.17 Get:16 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/universe amd64 Packages [779 kB]
#9 27.84 Get:17 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/main amd64 Packages [930 kB]
#9 28.18 Get:18 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security/multiverse amd64 Packages [27.6 kB]
#9 28.33 Fetched 18.4 MB in 27s (687 kB/s)
#9 28.33 Reading package lists...
#9 29.82 Reading package lists...
#9 31.35 Building dependency tree...
#9 31.60 Reading state information...
#9 31.74 Some packages could not be installed. This may mean that you have
#9 31.74 requested an impossible situation or if you are using the unstable
#9 31.74 distribution that some required packages have not yet been created
#9 31.74 or been moved out of Incoming.
#9 31.74 The following information may help to resolve the situation:
#9 31.74
#9 31.75 The following packages have unmet dependencies:
#9 31.91  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed
#9 31.91  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2 is to be installed
#9 31.91         Recommends: netbase but it is not going to be installed
#9 31.91  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed
#9 31.91  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed
#9 31.91               Depends: libc6-dev but it is not going to be installed or
#9 31.91                        libc-dev
#9 31.93 E: Unable to correct problems, you have held broken packages.
------
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 https://launchpad.proxy.ustclug.org/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php7.4-cli php7.4-dev        php7.4-pgsql php7.4-sqlite3 php7.4-gd        php7.4-curl php7.4-memcached        php7.4-imap php7.4-mysql php7.4-mbstring        php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap        php7.4-intl php7.4-readline php7.4-pcov        php7.4-msgpack php7.4-igbinary php7.4-ldap        php7.4-redis     && curl -so /usr/bin/composer https://mirrors.aliyun.com/composer/composer.phar     && chmod a+x /usr/bin/composer     && composer --version     && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/     && curl -sL https://deb.nodesource.com/setup_16.x | bash -     && apt-get install -y nodejs     && 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
ERROR: Service 'laravel.test' failed to build : Build failed

看报错信息好像是一些依赖的版本不对

然后我在7.4的DockerFile添加 RUN apt-get update\ 后面添加 && apt-get upgrade \ 希望在构建前更新源,不过还是失败了,报同样的错

RUN apt-get update \
    && apt-get upgrade \
    && 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 \

现在很懵逼,不知道是不是镜像源有问题,或者是对应的wsl的Ubuntu有问题

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 5

凡是100错误都是连接失败,尝试用浏览器访问你的报错地址,或者再次尝试,耐心等待

2年前 评论
DAmimi (楼主) 2年前

可能原因:

  1. 玄学
  2. 你需要换中科大的源 请参考我之前的经验
  3. 既然你可以科学,那么,就不要管那么多,直接按原生的文件构建环境,一丁点都不要改(我在公司就这么干的,也启动成功了)
2年前 评论

不知道楼主解决没有,报错的问题应该是依赖,gnupg依赖的gpgv需要版本低于2.2.19-3ubuntu2.1.1,而docker使用的21.04最高版本的gpgv是2.2.20-1ubuntu3,但如果我把dockerfile里的版本改为20.04的话这一步虽然能够成功,但是后面安装php8.0的时候又会报错需要21.04的依赖

2年前 评论

我理解的,是你的源有问题。运行过程中提示[internal] load metadata for docker.io/library/ubuntu:21.04,相应的源可以换一下,比如以下源:
deb mirrors.aliyun.com/ubuntu hirsute main restricted
deb mirrors.aliyun.com/ubuntu hirsute-updates main restricted
deb mirrors.aliyun.com/ubuntu hirsute universe
deb mirrors.aliyun.com/ubuntu hirsute-updates universe
deb mirrors.aliyun.com/ubuntu hirsute multiverse
deb mirrors.aliyun.com/ubuntu hirsute-updates multiverse
deb mirrors.aliyun.com/ubuntu hirsute-backports main restricted universe multiverse
deb mirrors.aliyun.com/ubuntu hirsute-security main restricted
deb cn.archive.ubuntu.com/ubuntu hirsute-security universe
deb cn.archive.ubuntu.com/ubuntu hirsute-security multiverse

我用的是ubuntu:20.04的加速源。那相应的DockerFile文件改成ubuntu:20.04,然后把相应的sources.list中的源换一下。比如是ubuntu:20.04的加速源:
deb mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

最后在执行./vendor/bin/sail up 之前,先把你原来docker上已经下载相关image移除掉。比如 sail-8.1/app。

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!