laravel sail 首次启动报错

环境是:wsl2 下的 Ubuntu 20.04 LTS

执行 cd school && ./vendor/bin/sail up 就报错

镜像源都换了

#0 434.1 Creating config file /etc/php/8.1/mods-available/xmlreader.ini with new version
#0 434.4
#0 434.4 Creating config file /etc/php/8.1/mods-available/xmlwriter.ini with new version
#0 435.0
#0 435.0 Creating config file /etc/php/8.1/mods-available/xsl.ini with new version
#0 435.5 Setting up dh-autoreconf (20) ...
#0 435.5 Setting up php8.1-dev (8.1.8-1+ubuntu22.04.1+deb.sury.org+1) ...
#0 435.5 update-alternatives: using /usr/bin/php-config8.1 to provide /usr/bin/php-config (php-config) in auto mode
#0 435.5 update-alternatives: warning: skip creation of /usr/share/man/man1/php-config.1.gz because associated file /usr/share/man/man1/php-config8.1.1.gz (of link group php-config) doesn't exist
#0 435.5 update-alternatives: using /usr/bin/phpize8.1 to provide /usr/bin/phpize (phpize) in auto mode
#0 435.5 update-alternatives: warning: skip creation of /usr/share/man/man1/phpize.1.gz because associated file /usr/share/man/man1/phpize8.1.1.gz (of link group phpize) doesn't exist
#0 435.5 Setting up g++ (4:11.2.0-1ubuntu1) ...
#0 435.6 update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
#0 435.6 update-alternatives: warning: skip creation of /usr/share/man/man1/c++.1.gz because associated file /usr/share/man/man1/g++.1.gz (of link group c++) doesn't exist
#0 435.6 Setting up php8.1-redis (5.3.7+4.3.0-1+ubuntu22.04.1+deb.sury.org+2) ...
#0 435.7 Setting up build-essential (12.9ubuntu3) ...
#0 435.7 Setting up php-pear (1:1.10.12+submodules+notgz+20210212-1ubuntu3) ...
#0 435.7 Setting up php8.1-memcached (3.2.0+2.2.0-1+ubuntu22.04.1+deb.sury.org+1) ...
#0 435.8 Setting up debhelper (13.6ubuntu1) ...
#0 435.8 Setting up pkg-php-tools (1.42build1) ...
#0 435.9 Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
#0 435.9 Processing triggers for php8.1-cli (8.1.8-1+ubuntu22.04.1+deb.sury.org+1) ...
#0 442.8 All settings correct for using Composer
#0 442.8 Downloading...
#0 447.4
#0 447.4 Composer (version 2.3.10) successfully installed to: /usr/bin/composer
#0 447.4 Use it: php /usr/bin/composer
#0 447.4
#0 448.2
#0 448.2 ## Installing the NodeSource Node.js 16.x repo...
#0 448.2
#0 448.2
#0 448.2 ## Populating apt-get cache...
#0 448.2
#0 448.2 + apt-get update
#0 448.9 Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
#0 448.9 Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
#0 449.1 Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
#0 449.4 Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
#0 449.5 Hit:5 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
#0 449.5 Reading package lists...
#0 450.1
#0 450.1 ## Installing packages required for setup: lsb-release...
#0 450.1
#0 450.1 + apt-get install -y lsb-release > /dev/null 2>&1
#0 453.5
#0 453.5 ## Your distribution, identified as "Ubuntu Jammy Jellyfish (development branch)", is a pre-release version of Ubuntu. NodeSource does not maintain official support for Ubuntu versions until they are formally released. You can try using the manual installation instructions available at https://github.com/nodesource/distributions and use the latest supported Ubuntu version name as the distribution identifier, although this is not guaranteed to work.
#0 453.5
------
failed to solve: 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     && echo "keyserver hkp://keyserver.ubuntu.com:80" >> ~/.gnupg/dirmngr.conf     && gpg --recv-key 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c     && gpg --export 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c > /usr/share/keyrings/ppa_ondrej_php.gpg     && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy 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('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer     && curl -sLS 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 | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null     && echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list     && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null     && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client-$POSTGRES_VERSION     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*]: exit code: 1
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 15
陈先生

先不要启动 NodeJs 看下

1年前 评论
laravel176 (楼主) 1年前
陈先生 (作者) 1年前

解决了么?我也是这个问题

1年前 评论

我你这是build失败了,可能是你的网络环境的问题吧,我有一个build好的包

laravel.test:
#        build:
#            context: ./vendor/laravel/sail/runtimes/8.1
#            dockerfile: Dockerfile
#            args:
#                WWWGROUP: '${WWWGROUP}'
        image: 'coloynle/sail-8.1:latest'

这样换一下就可以了

1年前 评论

这个和镜像源没关系,错误是Nodesource不支持构建使用的基础镜像。
个人的解决方案是直接修改Dockerfile,位置在./vendor/laravel/sail/runtimes/8.1
注释掉36行

&& curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \

然后在36行后面加上下面的代码、

    && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee "/usr/share/keyrings/nodesource.gpg" >/dev/null \
    && gpg --no-default-keyring --keyring "/usr/share/keyrings/nodesource.gpg" --list-keys \
    && echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x jammy main" | tee /etc/apt/sources.list.d/nodesource.list \
    && echo  "deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x jammy main" | tee -a /etc/apt/sources.list.d/nodesource.list \
    && apt-get update \

最后这段代码大概是这样的:

    && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
#    && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
    && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee "/usr/share/keyrings/nodesource.gpg" >/dev/null \
    && gpg --no-default-keyring --keyring "/usr/share/keyrings/nodesource.gpg" --list-keys \
    && echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x jammy main" | tee /etc/apt/sources.list.d/nodesource.list \
    && echo  "deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x jammy main" | tee -a /etc/apt/sources.list.d/nodesource.list \
    && apt-get update \
    && apt-get install -y nodejs \
    && npm install -g npm \

这样应该可以构建成功了。

1年前 评论
宇宙最厉害

安装node的问题:github.com/nodesource/distribution... 把 ubuntu:22.04 改成 20.04, jammy 改成 focal,或者直接用下面的

FROM ubuntu:20.04

LABEL maintainer="Taylor Otwell"

ARG WWWGROUP
ARG NODE_VERSION=16
ARG POSTGRES_VERSION=13

WORKDIR /var/www/html

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN sed -i -E 's/http:\/\/(archive|security).ubuntu.com/http:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list

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 \
    && echo "keyserver hkp://keyserver.ubuntu.com:80" >> ~/.gnupg/dirmngr.conf \
    && gpg --recv-key 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c \
    && gpg --export 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c > /usr/share/keyrings/ppa_ondrej_php.gpg \
    && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://launchpad.proxy.ustclug.org/ondrej/php/ubuntu focal 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('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && curl -sLS 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 | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null \
    && echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
    && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \
    && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && apt-get update \
    && apt-get install -y yarn \
    && apt-get install -y mysql-client \
    && apt-get install -y postgresql-client-$POSTGRES_VERSION \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1

RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail

COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container

EXPOSE 8000

ENTRYPOINT ["start-container"]
1年前 评论
Noctis 1年前

我找到原因,但还不知道怎么解决。是sail-8.1/app这个docker镜像的问题。它显示的是开发版,导致nodejs安装失败。

1年前 评论
Zelig (作者) 1年前

你的猜测没错,我也遇到了同样的问题,阿里云的镜像加速有问题,下来的ubuntu版本都是预发布版本,NodeSource不支持,导致sail up一直失败,最后我把docker engine里配的阿里云镜像删了就好了

1年前 评论
ImVic 1年前

卧槽 楼上这个方式可以

9个月前 评论
陈先生

:see_no_evil: 为什么要改镜像地址呢?是阿里云的包比官方的多么?不是很能理解。

9个月前 评论

我去,还真的是阿里云镜像的问题,找了两天啊,换源就好了

9个月前 评论

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