1.1 进入docker

docker exec -it  myphp-fpm73 bash
ls /usr/scr/php

查看是否已经下载,

1.2 如果没有此目录

docker-php-source extract

初始化此目录

1.3 退出容器

ctrl+Q+P

2 下载扩展

https://pecl.php.net/package/swoole

2.1 解压

tar zxvf swoole-4.6.3.tgz

2.2 重命名

mv swoole-4.6.3 swoole

2.3 复制到容器内

docker cp ./swoole myphp-fpm73:/usr/src/php/ext

3 安装

docker-php-ext-install swoole

3.1 查看是否安装成功

php -m|grep swoole

docker php-fpm 安装swoole扩展

3.2 查看swoole配置

php --ri swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.6.3
Built => Mar 11 2021 13:37:04
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608