【问题标题】:Laravel Sails Service 'laravel.test' failed to buildLaravel Sails 服务“laravel.test”构建失败
【发布时间】:2022-01-10 21:53:31
【问题描述】:

我在让 Laravel Sail 参与新的 laravel 8 项目时遇到问题,我在 Ubuntu 20.04 LTS 上,我按照 Laravel Sails Documentation 中的说明进行操作

到目前为止我所做的是:

首先我创建了一个新的 Laravel 项目:

composer create-project --prefer-dist laravel/laravel blog

然后安装帆:

composer require laravel/sail --dev

已发布sails的docker-compose.yml

php artisan sail:install

终于启航了:

./vendor/bin/sail up 

但是我收到了这个错误:

ERROR: Service 'laravel.test' failed to build

这是完整的错误信息:

Pulling mysql (mysql/mysql-server:8.0)...
8.0: Pulling from mysql/mysql-server
639d1bdfca05: Pull complete
9e100c7b198d: Pull complete
427d2cdb963c: Pull complete
4436dc023066: Pull complete
5800f7888dd1: Pull complete
798cd8b6d3ec: Pull complete
c5ce8d5cf40e: Pull complete
Digest: sha256:91170bd4e012f0bf46b5141a38b612427b37692e8465cdffe9b0ca2d74d37d8a
Status: Downloaded newer image for mysql/mysql-server:8.0
Building laravel.test
Step 1/18 : FROM ubuntu:21.04
21.04: Pulling from library/ubuntu
9e6a0d5477cf: Pull complete
Digest: sha256:93a94c12448f393522f44d8a1b34936b7f76890adea34b80b87a245524d1d574
Status: Downloaded newer image for ubuntu:21.04
 ---> d662230a2592
Step 2/18 : LABEL maintainer="Taylor Otwell"
 ---> Running in 89940512e780
Removing intermediate container 89940512e780
 ---> 2b6050bc73a0
Step 3/18 : ARG WWWGROUP
 ---> Running in c33ba5cd161c
Removing intermediate container c33ba5cd161c
 ---> cd665779f65a
Step 4/18 : ARG NODE_VERSION=16
 ---> Running in 1fab74b70fc7
Removing intermediate container 1fab74b70fc7
 ---> 9fc2b36920f3
Step 5/18 : WORKDIR /var/www/html
 ---> Running in 53a071a9db21
Removing intermediate container 53a071a9db21
 ---> cd9c5c32babc
Step 6/18 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in a9e045bff55e
Removing intermediate container a9e045bff55e
 ---> 0cc113458364
Step 7/18 : ENV TZ=UTC
 ---> Running in 9827c7d2f5e1
Removing intermediate container 9827c7d2f5e1
 ---> 0f209195f47a
Step 8/18 : RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 ---> Running in ccafa5e32e94
Removing intermediate container ccafa5e32e94
 ---> b58053a83ede
Step 9/18 : 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.1-cli php8.1-dev        php8.1-pgsql php8.1-sqlite3 php8.1-gd        php8.1-curl        php8.1-imap php8.1-mysql php8.1-mbstring        php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap        php8.1-intl php8.1-readline        php8.1-ldap        php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole        php8.1-memcached php8.1-pcov php8.1-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/*
 ---> Running in 279bb38a60ad
Err:1 http://archive.ubuntu.com/ubuntu hirsute InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu hirsute-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu hirsute-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu hirsute-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/hirsute/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/hirsute-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/hirsute-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/hirsute-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
Package ca-certificates is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package gnupg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gnupg' has no installation candidate
E: Unable to locate package gosu
E: Unable to locate package curl
E: Package 'ca-certificates' has no installation candidate
E: Unable to locate package zip
E: Unable to locate package unzip
E: Unable to locate package git
E: Unable to locate package supervisor
E: Unable to locate package sqlite3
E: Unable to locate package libcap2-bin
E: Unable to locate package libpng-dev
E: Unable to locate package python2
ERROR: Service 'laravel.test' failed to build: The command '/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.1-cli php8.1-dev        php8.1-pgsql php8.1-sqlite3 php8.1-gd        php8.1-curl        php8.1-imap php8.1-mysql php8.1-mbstring        php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap        php8.1-intl php8.1-readline        php8.1-ldap        php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole        php8.1-memcached php8.1-pcov php8.1-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/*' returned a non-zero code: 100

知道为什么会出现此错误,以及如何解决它吗?

【问题讨论】:

  • 你使用的是什么版本的 Docker?
  • 我现在才注意到,我正在使用旧版本的 docker.. 我正在运行 Ubuntu 16.04 并在升级过程中升级到 20.04,docker repo 被禁用,我最终没有升级 docker 以保持安静一次..我认为安装新版本的 docker 会修复错误,对吗?无论如何,我将升级我的 docker 安装以使用最新的稳定存储库。
  • 根据this GitHub issue的说法,解决了少数人的问题。
  • 我会试试这个
  • 升级 docker 确实解决了这个问题。

标签: php laravel docker laravel-8 laravel-sail


【解决方案1】:

基本上这个错误意味着容器和互联网之间没有连接,但我无法弄清楚为什么会发生这种情况。

感谢Rwd 在评论部分提到这个Github Issue 我注意到我使用的是旧版本的docker,我运行的是 Ubuntu 16.04 .. 后来我升级到 20.04,在升级过程中 docker存储库被禁用,所以我最终没有安静地升级 docker。

所以我所做的只是重新安装docker

我删除了旧版本

sudo apt-get remove docker docker-engine docker.io containerd runc

更新 apt 包索引并安装包以允许 apt 通过 HTTPS 使用存储库:

sudo apt  update

 sudo apt  install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

添加 Docker 的官方 GPG 密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

设置稳定的存储库:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

最后:

 sudo apt update

 sudo apt install docker-ce docker-ce-cli containerd.io

由于我在跳过之前已经完成了安装后步骤,因此在重新启动 docker 后,错误消失了,sail up 运行成功

【讨论】:

    猜你喜欢
    • 2014-01-26
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 2019-01-09
    • 2016-02-27
    • 1970-01-01
    相关资源
    最近更新 更多