聊聊关于Mac Laravel docker sail 搭建问题

广告:宝塔Linux面板高效运维的服务器管理软件 点击【 https://www.bt.cn/p/uNLv1L 】立即购买

聊聊关于Mac Laravel docker sail 搭建问题

先写段独白

两年多没用php写过代码了,现在从新捡起来,以前用tp,但tp的版本更新很不友好,所以这次一步到位用Laravel。先docker环境开始吧,我会一边尝试一边写,也欢迎大家和我互动,多教我一些东西。我也希望我的新手经验可以帮到一些人。

【推荐:laravel教程

一. docker Desktop安装

论坛里详细教程

二. 运行容器(遇到「坑」了!)

我就是按照教程一步一步操作的,直到第六步我的运行并没有很顺利,出现了以下情况

ERROR: Service 'laravel.test' failed to build : Build failed
登录后复制

我在仔细看了一下日志,错误出现在

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.
登录后复制

有很多依赖貌似有问题

#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed
登录后复制

应该是更高的版本被安装了,于是我尝试替换apt-get使用aptitudeapt-get 不同的是,aptitude 在处理依赖问题上更佳一些。举例来说,aptitude 在删除一个包时,会同时删除本身所依赖的包。这样,系统中不会残留无用的包,整个系统更为干净。

于是我调整了一下Dockerfile

RUN apt-get update \    && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
登录后复制

变成了

RUN apt-get update \    && apt-get install -y aptitude \    && aptitude install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
登录后复制

再次运行./vendor/bin/#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262 gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264 perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264 Recommends: netbase but it is not going to be installed#9 7.264 perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265 zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265 Depends: libc6-dev but it is not going to be installed or#9 7.265 libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.9情况变得不同了,但依然报了错误

#9 32.31 E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
登录后复制

并没有安装成功,只是执行了过去又尝试了apt-get install -f但依然没什么效果

好吧,换个思路观察了一下,既然说的更高版本已经安装,那我就基于更高的ubuntu去做,于是我修改了FROM,从

FROM ubuntu:21.04
登录后复制

改到了

FROM ubuntu:latest
登录后复制

好吧,新的依赖问题来了

#9 44.96 Some packages could not be installed. This may mean that you have#9 44.96 requested an impossible situation or if you are using the unstable#9 44.96 distribution that some required packages have not yet been created#9 44.96 or been moved out of Incoming.#9 44.96 The following information may help to resolve the situation:#9 44.96#9 44.96 The following packages have unmet dependencies:#9 45.08  php8.0-bcmath : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-cli : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08               Depends: php8.0-opcache but it is not going to be installed#9 45.08               Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08               Depends: libxml2 (>= 2.8.0) but it is not going to be installed#9 45.08  php8.0-curl : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-dev : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08               Recommends: pkg-php-tools but it is not going to be installed#9 45.08  php8.0-gd : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-igbinary : Depends: php8.0-common but it is not going to be installed#9 45.08  php8.0-imap : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-intl : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08                Depends: libicu67 (>= 67.1-1~) but it is not installable#9 45.08  php8.0-ldap : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-mbstring : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-memcached : Depends: php8.0-common but it is not going to be installed#9 45.08  php8.0-msgpack : Depends: php8.0-common but it is not going to be installed#9 45.08  php8.0-mysql : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-pcov : Depends: php8.0-common but it is not going to be installed#9 45.08                Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08  php8.0-pgsql : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-readline : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-redis : Depends: php8.0-common but it is not going to be installed#9 45.08  php8.0-soap : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08                Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08                Depends: libxml2 (>= 2.7.4) but it is not going to be installed#9 45.08  php8.0-sqlite3 : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08  php8.0-swoole : Depends: php8.0-common but it is not going to be installed#9 45.08                  Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08  php8.0-xdebug : Depends: php8.0-common but it is not going to be installed#9 45.08                  Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08  php8.0-xml : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08               Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08               Depends: libxml2 (>= 2.9.0) but it is not going to be installed#9 45.08               Depends: libxslt1.1 (>= 1.1.25) but it is not going to be installed#9 45.08  php8.0-zip : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed#9 45.08               Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed#9 45.08               Depends: libzip4 (>= 1.7.0) but it is not installable#9 45.10 E: Unable to correct problems, you have held broken packages.
登录后复制

搜索了一下,貌似找到了一个解决方案

 Solve it with downgrade sail composer require laravel/sail:^1.7.0 php artisan sail:install and in ubuntu terminal sail up --build
登录后复制

好,继续尝试,首先运行

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.0
登录后复制登录后复制

发现报错,具体错误忘记了。我看了一下php版本是7.x于是使用brew install php 发现报错

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.1
登录后复制

看了一下是没权限,使用sudo brew install php

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.2
登录后复制

发现sudo不支持。于是sudo chown -R $(whoami) /usr/local/Cellar改变目录权限正常运行使用php -v看了一下版本,还是7.0使用brew unlink php70brew link phpsudo vim ~/.bash_profile在文件末尾追加

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.3
登录后复制

php -vphp8.0安装成功

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.4
登录后复制

继续

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.0
登录后复制登录后复制

发现没有没有找到,想到可能是国内composer源有问题

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.6
登录后复制

我是安装了composer 的中国镜像,其实就是composer 的中国镜像出了问题,后来我直接把他改了,换成另外一个地址就行了

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.7
登录后复制

成功。第二步

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.8
登录后复制

成功。第三步

#9 7.166 Some packages could not be installed. This may mean that you have#9 7.166 requested an impossible situation or if you are using the unstable#9 7.166 distribution that some required packages have not yet been created#9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262  gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed#9 7.264  perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed#9 7.264         Recommends: netbase but it is not going to be installed#9 7.264  perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed#9 7.265  zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed#9 7.265               Depends: libc6-dev but it is not going to be installed or#9 7.265                        libc-dev#9 7.283 E: Unable to correct problems, you have held broken packages.9
登录后复制

成功。解决问题。最后localhost

以上就是聊聊关于Mac Laravel docker sail 搭建问题的详细内容,更多请关注9543建站博客其它相关文章!

广告:SSL证书一年128.66元起,点击购买~~~

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。
作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:介绍关于Xdebug提示不支持php7.0的坑
下一篇:如何用PHP正则表达式验证用户输入的字符串是否为数字

发表评论

关闭广告
关闭广告