在 Windows 10 专业版中创建 weibo 应用,基于 Laravel Sail 开发环境

1、使用 Composer 创建一个名为 weibo 的应用。打开 Windows Terminal 命令行,按照以下指示进入 Ubuntu 系统。如图1

使用 Composer 创建一个名为 weibo 的应用。打开 Windows Terminal 命令行,按照以下指示进入 Ubuntu 系统。

图1

2、Ubuntu 作为 Windows 子系统,可以访问到主系统下的硬盘。为了方便管理代码,我在 E 盘下早已创建了 wwwroot 目录,进入此目录后,使用以下命令进行创建一个测试的 Laravel 项目,名称:weibo。如图2

Ubuntu 作为 Windows 子系统,可以访问到主系统下的硬盘。为了方便管理代码,我在 E 盘下早已创建了 wwwroot 目录,进入此目录后,使用以下命令进行创建一个测试的 Laravel 项目,名称:weibo。

图2

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$ curl -s https://laravel.build/weibo | bash
_                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` / / / / _ / |
| |___| (_| | | | (_| |/ V /  __/ |
|______/__,_|_|  /__,_| /_/ /___|_|
Warning: TTY mode requires /dev/tty to be read/writable.
Creating a "laravel/laravel" project at "./weibo"
Installing laravel/laravel (v8.6.9)
- Downloading laravel/laravel (v8.6.9)
- Installing laravel/laravel (v8.6.9): Extracting archive
Created project in /opt/weibo
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 110 installs, 0 updates, 0 removals
- Locking asm89/stack-cors (v2.0.3)
- Locking brick/math (0.9.3)
- Locking dflydev/dot-access-data (v3.0.1)
- Locking doctrine/inflector (2.0.4)
- Locking doctrine/instantiator (1.4.0)
- Locking doctrine/lexer (1.2.1)
- Locking dragonmantank/cron-expression (v3.1.0)
- Locking egulias/email-validator (2.1.25)
- Locking facade/flare-client-php (1.9.1)
- Locking facade/ignition (2.17.2)
- Locking facade/ignition-contracts (1.0.2)
- Locking fakerphp/faker (v1.17.0)
- Locking filp/whoops (2.14.4)
- Locking fruitcake/laravel-cors (v2.0.4)
- Locking graham-campbell/result-type (v1.0.4)
- Locking guzzlehttp/guzzle (7.4.1)
- Locking guzzlehttp/promises (1.5.1)
- Locking guzzlehttp/psr7 (2.1.0)
- Locking hamcrest/hamcrest-php (v2.0.1)
- Locking laravel/framework (v8.76.2)
- Locking laravel/sail (v1.12.12)
- Locking laravel/sanctum (v2.13.0)
- Locking laravel/serializable-closure (v1.0.5)
- Locking laravel/tinker (v2.6.3)
- Locking league/commonmark (2.1.0)
- Locking league/config (v1.1.1)
- Locking league/flysystem (1.1.9)
- Locking league/mime-type-detection (1.9.0)
- Locking mockery/mockery (1.4.4)
- Locking monolog/monolog (2.3.5)
- Locking myclabs/deep-copy (1.10.2)
- Locking nesbot/carbon (2.55.2)
- Locking nette/schema (v1.2.2)
- Locking nette/utils (v3.2.6)
- Locking nikic/php-parser (v4.13.2)
- Locking nunomaduro/collision (v5.10.0)
- Locking opis/closure (3.6.2)
- Locking phar-io/manifest (2.0.3)
- Locking phar-io/version (3.1.0)
- Locking phpdocumentor/reflection-common (2.2.0)
- Locking phpdocumentor/reflection-docblock (5.3.0)
- Locking phpdocumentor/type-resolver (1.5.1)
- Locking phpoption/phpoption (1.8.1)
- Locking phpspec/prophecy (v1.15.0)
- Locking phpunit/php-code-coverage (9.2.10)
- Locking phpunit/php-file-iterator (3.0.6)
- Locking phpunit/php-invoker (3.1.1)
- Locking phpunit/php-text-template (2.0.4)
- Locking phpunit/php-timer (5.0.3)
- Locking phpunit/phpunit (9.5.10)
- Locking psr/container (1.1.2)
- Locking psr/event-dispatcher (1.0.0)
- Locking psr/http-client (1.0.1)
- Locking psr/http-factory (1.0.1)
- Locking psr/http-message (1.0.1)
- Locking psr/log (2.0.0)
- Locking psr/simple-cache (1.0.1)
- Locking psy/psysh (v0.10.12)
- Locking ralouphie/getallheaders (3.0.3)
- Locking ramsey/collection (1.2.2)
- Locking ramsey/uuid (4.2.3)
- Locking sebastian/cli-parser (1.0.1)
- Locking sebastian/code-unit (1.0.8)
- Locking sebastian/code-unit-reverse-lookup (2.0.3)
- Locking sebastian/comparator (4.0.6)
- Locking sebastian/complexity (2.0.2)
- Locking sebastian/diff (4.0.4)
- Locking sebastian/environment (5.1.3)
- Locking sebastian/exporter (4.0.4)
- Locking sebastian/global-state (5.0.3)
- Locking sebastian/lines-of-code (1.0.3)
- Locking sebastian/object-enumerator (4.0.4)
- Locking sebastian/object-reflector (2.0.4)
- Locking sebastian/recursion-context (4.0.4)
- Locking sebastian/resource-operations (3.0.3)
- Locking sebastian/type (2.3.4)
- Locking sebastian/version (3.0.2)
- Locking swiftmailer/swiftmailer (v6.3.0)
- Locking symfony/console (v5.4.1)
- Locking symfony/css-selector (v6.0.1)
- Locking symfony/deprecation-contracts (v3.0.0)
- Locking symfony/error-handler (v5.4.1)
- Locking symfony/event-dispatcher (v6.0.1)
- Locking symfony/event-dispatcher-contracts (v3.0.0)
- Locking symfony/finder (v5.4.0)
- Locking symfony/http-foundation (v5.4.1)
- Locking symfony/http-kernel (v5.4.1)
- Locking symfony/mime (v5.4.0)
- Locking symfony/polyfill-ctype (v1.23.0)
- Locking symfony/polyfill-iconv (v1.23.0)
- Locking symfony/polyfill-intl-grapheme (v1.23.1)
- Locking symfony/polyfill-intl-idn (v1.23.0)
- Locking symfony/polyfill-intl-normalizer (v1.23.0)
- Locking symfony/polyfill-mbstring (v1.23.1)
- Locking symfony/polyfill-php72 (v1.23.0)
- Locking symfony/polyfill-php73 (v1.23.0)
- Locking symfony/polyfill-php80 (v1.23.1)
- Locking symfony/polyfill-php81 (v1.23.0)
- Locking symfony/process (v5.4.0)
- Locking symfony/routing (v5.4.0)
- Locking symfony/service-contracts (v2.4.1)
- Locking symfony/string (v6.0.1)
- Locking symfony/translation (v6.0.1)
- Locking symfony/translation-contracts (v3.0.0)
- Locking symfony/var-dumper (v5.4.1)
- Locking theseer/tokenizer (1.2.1)
- Locking tijsverkoyen/css-to-inline-styles (2.2.4)
- Locking vlucas/phpdotenv (v5.4.1)
- Locking voku/portable-ascii (1.5.6)
- Locking webmozart/assert (1.10.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 110 installs, 0 updates, 0 removals
- Downloading doctrine/inflector (2.0.4)
- Downloading doctrine/lexer (1.2.1)
- Downloading dragonmantank/cron-expression (v3.1.0)
- Downloading symfony/var-dumper (v5.4.1)
- Downloading symfony/string (v6.0.1)
- Downloading psr/container (1.1.2)
- Downloading symfony/service-contracts (v2.4.1)
- Downloading symfony/console (v5.4.1)
- Downloading psr/log (2.0.0)
- Downloading monolog/monolog (2.3.5)
- Downloading voku/portable-ascii (1.5.6)
- Downloading phpoption/phpoption (1.8.1)
- Downloading graham-campbell/result-type (v1.0.4)
- Downloading vlucas/phpdotenv (v5.4.1)
- Downloading symfony/css-selector (v6.0.1)
- Downloading tijsverkoyen/css-to-inline-styles (2.2.4)
- Downloading symfony/routing (v5.4.0)
- Downloading symfony/polyfill-php72 (v1.23.0)
- Downloading symfony/polyfill-intl-idn (v1.23.0)
- Downloading symfony/mime (v5.4.0)
- Downloading symfony/http-foundation (v5.4.1)
- Downloading psr/event-dispatcher (1.0.0)
- Downloading symfony/event-dispatcher-contracts (v3.0.0)
- Downloading symfony/event-dispatcher (v6.0.1)
- Downloading symfony/error-handler (v5.4.1)
- Downloading symfony/http-kernel (v5.4.1)
- Downloading symfony/finder (v5.4.0)
- Downloading symfony/polyfill-iconv (v1.23.0)
- Downloading egulias/email-validator (2.1.25)
- Downloading swiftmailer/swiftmailer (v6.3.0)
- Downloading symfony/polyfill-php81 (v1.23.0)
- Downloading ramsey/collection (1.2.2)
- Downloading brick/math (0.9.3)
- Downloading ramsey/uuid (4.2.3)
- Downloading psr/simple-cache (1.0.1)
- Downloading opis/closure (3.6.2)
- Downloading symfony/translation-contracts (v3.0.0)
- Downloading symfony/translation (v6.0.1)
- Downloading nesbot/carbon (2.55.2)
- Downloading league/mime-type-detection (1.9.0)
- Downloading league/flysystem (1.1.9)
- Downloading nette/utils (v3.2.6)
- Downloading nette/schema (v1.2.2)
- Downloading dflydev/dot-access-data (v3.0.1)
- Downloading league/config (v1.1.1)
- Downloading league/commonmark (2.1.0)
- Downloading laravel/serializable-closure (v1.0.5)
- Downloading laravel/framework (v8.76.2)
- Downloading facade/ignition-contracts (1.0.2)
- Downloading facade/flare-client-php (1.9.1)
- Downloading facade/ignition (2.17.2)
- Downloading fakerphp/faker (v1.17.0)
- Downloading asm89/stack-cors (v2.0.3)
- Downloading fruitcake/laravel-cors (v2.0.4)
- Downloading psr/http-message (1.0.1)
- Downloading psr/http-client (1.0.1)
- Downloading ralouphie/getallheaders (3.0.3)
- Downloading psr/http-factory (1.0.1)
- Downloading guzzlehttp/psr7 (2.1.0)
- Downloading guzzlehttp/promises (1.5.1)
- Downloading guzzlehttp/guzzle (7.4.1)
- Downloading laravel/sail (v1.12.12)
- Downloading laravel/sanctum (v2.13.0)
- Downloading nikic/php-parser (v4.13.2)
- Downloading psy/psysh (v0.10.12)
- Downloading laravel/tinker (v2.6.3)
- Downloading hamcrest/hamcrest-php (v2.0.1)
- Downloading mockery/mockery (1.4.4)
- Downloading filp/whoops (2.14.4)
- Downloading nunomaduro/collision (v5.10.0)
- Downloading phpunit/php-file-iterator (3.0.6)
- Downloading phpunit/php-code-coverage (9.2.10)
- Downloading phpspec/prophecy (v1.15.0)
- Installing doctrine/inflector (2.0.4): Extracting archive
- Installing doctrine/lexer (1.2.1): Extracting archive
- Installing symfony/polyfill-ctype (v1.23.0): Extracting archive
- Installing webmozart/assert (1.10.0): Extracting archive
- Installing dragonmantank/cron-expression (v3.1.0): Extracting archive
- Installing symfony/polyfill-php80 (v1.23.1): Extracting archive
- Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive
- Installing symfony/var-dumper (v5.4.1): Extracting archive
- Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive
- Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive
- Installing symfony/string (v6.0.1): Extracting archive
- Installing psr/container (1.1.2): Extracting archive
- Installing symfony/service-contracts (v2.4.1): Extracting archive
- Installing symfony/polyfill-php73 (v1.23.0): Extracting archive
- Installing symfony/deprecation-contracts (v3.0.0): Extracting archive
- Installing symfony/console (v5.4.1): Extracting archive
- Installing psr/log (2.0.0): Extracting archive
- Installing monolog/monolog (2.3.5): Extracting archive
- Installing voku/portable-ascii (1.5.6): Extracting archive
- Installing phpoption/phpoption (1.8.1): Extracting archive
- Installing graham-campbell/result-type (v1.0.4): Extracting archive
- Installing vlucas/phpdotenv (v5.4.1): Extracting archive
- Installing symfony/css-selector (v6.0.1): Extracting archive
- Installing tijsverkoyen/css-to-inline-styles (2.2.4): Extracting archive
- Installing symfony/routing (v5.4.0): Extracting archive
- Installing symfony/process (v5.4.0): Extracting archive
- Installing symfony/polyfill-php72 (v1.23.0): Extracting archive
- Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive
- Installing symfony/mime (v5.4.0): Extracting archive
- Installing symfony/http-foundation (v5.4.1): Extracting archive
- Installing psr/event-dispatcher (1.0.0): Extracting archive
- Installing symfony/event-dispatcher-contracts (v3.0.0): Extracting archive
- Installing symfony/event-dispatcher (v6.0.1): Extracting archive
- Installing symfony/error-handler (v5.4.1): Extracting archive
- Installing symfony/http-kernel (v5.4.1): Extracting archive
- Installing symfony/finder (v5.4.0): Extracting archive
- Installing symfony/polyfill-iconv (v1.23.0): Extracting archive
- Installing egulias/email-validator (2.1.25): Extracting archive
- Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
- Installing symfony/polyfill-php81 (v1.23.0): Extracting archive
- Installing ramsey/collection (1.2.2): Extracting archive
- Installing brick/math (0.9.3): Extracting archive
- Installing ramsey/uuid (4.2.3): Extracting archive
- Installing psr/simple-cache (1.0.1): Extracting archive
- Installing opis/closure (3.6.2): Extracting archive
- Installing symfony/translation-contracts (v3.0.0): Extracting archive
- Installing symfony/translation (v6.0.1): Extracting archive
- Installing nesbot/carbon (2.55.2): Extracting archive
- Installing league/mime-type-detection (1.9.0): Extracting archive
- Installing league/flysystem (1.1.9): Extracting archive
- Installing nette/utils (v3.2.6): Extracting archive
- Installing nette/schema (v1.2.2): Extracting archive
- Installing dflydev/dot-access-data (v3.0.1): Extracting archive
- Installing league/config (v1.1.1): Extracting archive
- Installing league/commonmark (2.1.0): Extracting archive
- Installing laravel/serializable-closure (v1.0.5): Extracting archive
- Installing laravel/framework (v8.76.2): Extracting archive
- Installing facade/ignition-contracts (1.0.2): Extracting archive
- Installing facade/flare-client-php (1.9.1): Extracting archive
- Installing facade/ignition (2.17.2): Extracting archive
- Installing fakerphp/faker (v1.17.0): Extracting archive
- Installing asm89/stack-cors (v2.0.3): Extracting archive
- Installing fruitcake/laravel-cors (v2.0.4): Extracting archive
- Installing psr/http-message (1.0.1): Extracting archive
- Installing psr/http-client (1.0.1): Extracting archive
- Installing ralouphie/getallheaders (3.0.3): Extracting archive
- Installing psr/http-factory (1.0.1): Extracting archive
- Installing guzzlehttp/psr7 (2.1.0): Extracting archive
- Installing guzzlehttp/promises (1.5.1): Extracting archive
- Installing guzzlehttp/guzzle (7.4.1): Extracting archive
- Installing laravel/sail (v1.12.12): Extracting archive
- Installing laravel/sanctum (v2.13.0): Extracting archive
- Installing nikic/php-parser (v4.13.2): Extracting archive
- Installing psy/psysh (v0.10.12): Extracting archive
- Installing laravel/tinker (v2.6.3): Extracting archive
- Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
- Installing mockery/mockery (1.4.4): Extracting archive
- Installing filp/whoops (2.14.4): Extracting archive
- Installing nunomaduro/collision (v5.10.0): Extracting archive
- Installing phpdocumentor/reflection-common (2.2.0): Extracting archive
- Installing phpdocumentor/type-resolver (1.5.1): Extracting archive
- Installing phpdocumentor/reflection-docblock (5.3.0): Extracting archive
- Installing sebastian/version (3.0.2): Extracting archive
- Installing sebastian/type (2.3.4): Extracting archive
- Installing sebastian/resource-operations (3.0.3): Extracting archive
- Installing sebastian/recursion-context (4.0.4): Extracting archive
- Installing sebastian/object-reflector (2.0.4): Extracting archive
- Installing sebastian/object-enumerator (4.0.4): Extracting archive
- Installing sebastian/global-state (5.0.3): Extracting archive
- Installing sebastian/exporter (4.0.4): Extracting archive
- Installing sebastian/environment (5.1.3): Extracting archive
- Installing sebastian/diff (4.0.4): Extracting archive
- Installing sebastian/comparator (4.0.6): Extracting archive
- Installing sebastian/code-unit (1.0.8): Extracting archive
- Installing sebastian/cli-parser (1.0.1): Extracting archive
- Installing phpunit/php-timer (5.0.3): Extracting archive
- Installing phpunit/php-text-template (2.0.4): Extracting archive
- Installing phpunit/php-invoker (3.1.1): Extracting archive
- Installing phpunit/php-file-iterator (3.0.6): Extracting archive
- Installing theseer/tokenizer (1.2.1): Extracting archive
- Installing sebastian/lines-of-code (1.0.3): Extracting archive
- Installing sebastian/complexity (2.0.2): Extracting archive
- Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive
- Installing phpunit/php-code-coverage (9.2.10): Extracting archive
- Installing doctrine/instantiator (1.4.0): Extracting archive
- Installing phpspec/prophecy (v1.15.0): Extracting archive
- Installing phar-io/version (3.1.0): Extracting archive
- Installing phar-io/manifest (2.0.3): Extracting archive
- Installing myclabs/deep-copy (1.10.2): Extracting archive
- Installing phpunit/phpunit (9.5.10): Extracting archive
76 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate/Foundation/ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
77 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
> @php artisan key:generate --ansi
Application key set successfully.
Application ready! Build something amazing.
Sail scaffolding installed successfully.
Please provide your password so we can make some final adjustments to your application's permissions.
[sudo] password for wangqiang:
Thank you! We hope you build something incredible. Dive in with: cd weibo && ./vendor/bin/sail up
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot$

3、进入目录:weibo,运行命令:./vendor/bin/sail build。报错:FileNotFoundError: [Errno 2] No such file or directory。[7207] Failed to execute script docker-compose。如图3

进入目录:weibo,运行命令:./vendor/bin/sail build。报错:FileNotFoundError: [Errno 2] No such file or directory。[7207] Failed to execute script docker-compose。

图3

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/weibo$ ./vendor/bin/sail build
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose/cli/main.py", line 81, in main
File "compose/cli/main.py", line 200, in perform_command
File "compose/cli/command.py", line 70, in project_from_options
File "compose/cli/command.py", line 146, in get_project
File "compose/cli/command.py", line 206, in get_project_name
File "posixpath.py", line 383, in abspath
FileNotFoundError: [Errno 2] No such file or directory
[7185] Failed to execute script docker-compose
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose/cli/main.py", line 81, in main
File "compose/cli/main.py", line 200, in perform_command
File "compose/cli/command.py", line 70, in project_from_options
File "compose/cli/command.py", line 146, in get_project
File "compose/cli/command.py", line 206, in get_project_name
File "posixpath.py", line 383, in abspath
FileNotFoundError: [Errno 2] No such file or directory
[7197] Failed to execute script docker-compose
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose/cli/main.py", line 81, in main
File "compose/cli/main.py", line 200, in perform_command
File "compose/cli/command.py", line 70, in project_from_options
File "compose/cli/command.py", line 146, in get_project
File "compose/cli/command.py", line 206, in get_project_name
File "posixpath.py", line 383, in abspath
FileNotFoundError: [Errno 2] No such file or directory
[7207] Failed to execute script docker-compose
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/weibo$

4、关闭 Docker Desktop,重新打开 Docker Desktop,删除容器 weibo。再次执行命令:./vendor/bin/sail build。运行命令:./vendor/bin/sail up -d。报错:ERROR: for weibo_laravel.test_1 Cannot start service laravel.test: driver failed programming external connectivity on endpoint weibo_laravel.test_1 (103c7d0eca8c6625d55c959f6b4a3fbe7921b8f12d29474519bcde62b876a555): Bind for 0.0.0.0:80 failed: port is already allocated。如图4

关闭 Docker Desktop,重新打开 Docker Desktop,删除容器 weibo。再次执行命令:./vendor/bin/sail build。运行命令:./vendor/bin/sail up -d。报错:ERROR: for weibo_laravel.test_1  Cannot start service laravel.test: driver failed programming external connectivity on endpoint weibo_laravel.test_1 (103c7d0eca8c6625d55c959f6b4a3fbe7921b8f12d29474519bcde62b876a555): Bind for 0.0.0.0:80 failed: port is already allocated。

图4

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/weibo$ ./vendor/bin/sail build
weibo_laravel.test_1   start-container                  Exit 128
Shutting down old Sail processes...
mysql uses an image, skipping
redis uses an image, skipping
meilisearch uses an image, skipping
mailhog uses an image, skipping
selenium uses an image, skipping
Building laravel.test
[+] Building 6.3s (16/16) FINISHED
=> [internal] load build definition from Dockerfile                                                               0.8s
=> => transferring dockerfile: 38B                                                                                0.0s
=> [internal] load .dockerignore                                                                                  1.1s
=> => transferring context: 2B                                                                                    0.0s
=> [internal] load metadata for docker.io/library/ubuntu:21.04                                                    4.7s
=> [ 1/11] FROM docker.io/library/ubuntu:21.04@sha256:93a94c12448f393522f44d8a1b34936b7f76890adea34b80b87a245524  0.0s
=> [internal] load build context                                                                                  0.2s
=> => transferring context: 99B                                                                                   0.0s
=> CACHED [ 2/11] WORKDIR /var/www/html                                                                           0.0s
=> CACHED [ 3/11] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone                  0.0s
=> CACHED [ 4/11] RUN apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git sup  0.0s
=> CACHED [ 5/11] RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1                                           0.0s
=> CACHED [ 6/11] RUN groupadd --force -g 1000 sail                                                               0.0s
=> CACHED [ 7/11] RUN useradd -ms /bin/bash --no-user-group -g 1000 -u 1337 sail                                  0.0s
=> CACHED [ 8/11] COPY start-container /usr/local/bin/start-container                                             0.0s
=> CACHED [ 9/11] COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf                                   0.0s
=> CACHED [10/11] COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini                                                0.0s
=> CACHED [11/11] RUN chmod +x /usr/local/bin/start-container                                                     0.0s
=> exporting to image                                                                                             0.0s
=> => exporting layers                                                                                            0.0s
=> => writing image sha256:e61442fd4297b3cb8dcc44e9c4501ba75eae255b6a7940040df40f49b04481bf                       0.0s
=> => naming to sail-8.1/app                                                                                      0.0s
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/weibo$ ./vendor/bin/sail up -d
Creating network "weibo_sail" with driver "bridge"
Creating weibo_mailhog_1     ... done
Creating weibo_meilisearch_1 ... done
Creating weibo_redis_1       ... done
Creating weibo_mysql_1       ... done
Creating weibo_selenium_1    ... done
Creating weibo_laravel.test_1 ...
Creating weibo_laravel.test_1 ... error
ERROR: for weibo_laravel.test_1  Cannot start service laravel.test: driver failed programming external connectivity on endpoint weibo_laravel.test_1 (103c7d0eca8c6625d55c959f6b4a3fbe7921b8f12d29474519bcde62b876a555): Bind for 0.0.0.0:80 failed: port is already allocated
ERROR: for laravel.test  Cannot start service laravel.test: driver failed programming external connectivity on endpoint weibo_laravel.test_1 (103c7d0eca8c6625d55c959f6b4a3fbe7921b8f12d29474519bcde62b876a555): Bind for 0.0.0.0:80 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/weibo$

5、打开 Docker Desktop,停止容器 example-app。以让出端口 80,以及其他有冲突的端口。后续计划支持多个 Laravel Sail 环境并设定自己想要的域名。如图5

打开 Docker Desktop,停止容器 example-app。以让出端口 80,以及其他有冲突的端口。后续计划支持多个 Laravel Sail 环境并设定自己想要的域名。

图5

6、运行命令:./vendor/bin/sail up -d。创建容器成功。如图6

运行命令:./vendor/bin/sail up -d。创建容器成功。

图6

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/weibo$ ./vendor/bin/sail up -d
weibo_laravel.test_1   start-container                  Exit 128
Shutting down old Sail processes...
Creating network "weibo_sail" with driver "bridge"
Creating weibo_mailhog_1      ... done
Creating weibo_selenium_1    ... done
Creating weibo_mysql_1       ... done
Creating weibo_redis_1       ... done
Creating weibo_meilisearch_1 ... done
Creating weibo_laravel.test_1 ... done

7、编辑 C:/Windows/System32/Drivers/etc/hosts 文件,指定 IP 与域名之间的映射关系。

127.0.0.1 weibo.test

8、在浏览器中打开网址:http://weibo.test/ 。响应 200。如图7

在浏览器中打开网址:http://weibo.test/ 。响应 200。

图7

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250691.html

(0)
上一篇 2022年5月1日
下一篇 2022年5月1日

相关推荐

发表回复

登录后才能评论