
###1.下载镜像
pull php 镜像
```
docker pull php:7.3-alpine3.8
```
创建容器
```
docker run -it --name test php:7.3-alpine3.8 sh
```
###2.进入容器安装swoole
```
# 安装依赖的第三方包
echo http://mirrors.ustc.edu.cn/alpine/v3.7/main > /etc/apk/repositories && \
echo http://mirrors.ustc.edu.cn/alpine/v3.7/community >> /etc/apk/repositories
apk --no-cache add autoconf gcc g++ make openssl openssl-dev
#下载swoole
pecl install swoole-4.3.1
#开启扩展
docker-php-ext-enable swoole
#查看扩展
php -m
#将目前环境打包成新镜像
docker commit test swoole:4.3.1
```
###3.创建swoole容器
```
docker run -it --name swoole \
-p 80:80 \
-v /home/my/lujing:/pro \
swoole:4.3.1 sh
```
###4.设置基本目录(app)
```
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
```
执行composer dump-autoload映射app目录
###创建一个http服务
```
$http = new Swoole\Http\Server("0.0.0.0", 80);
$http->on('request', function ($request,Swoole\Http\Response $response) {
$response->end("
hello
");
});
$http->start();
```