美文网首页
docker for windows 使用swoole并推送到d

docker for windows 使用swoole并推送到d

作者: charmingcheng | 来源:发表于2022-07-21 11:56 被阅读0次

本地拉取镜像:

docker pull phpswoole/swoole:4.5.9-php7.4

测试镜像环境:

docker run --rm phpswoole/swoole:4.5.9-php7.4 "php -m"
docker run --rm phpswoole/swoole:4.5.9-php7.4 "php --ri swoole"
docker run --rm phpswoole/swoole:4.5.9-php7.4 "composer --version"

服务代码 D:\docker\swoole\server.php

<?php
$http = new Swoole\Http\Server('0.0.0.0', 9501);

$http->on('Request', function ($request, $response) {
    $response->header('Content-Type', 'text/html; charset=utf-8');
    $response->end('<h1>Hello Swoole. #' . rand(1000, 9999) . '</h1>');
});

$http->start();

启动容器

docker run --rm -p 8000:9501 --name swoole -v D:\docker\swoole:/var/www phpswoole/swoole:4.5.9-php7.4

浏览器查看localhost:8000

image.png

查看所有容器

docker ps -a
image.png

进入容器

docker exec -it [CONTAINER ID] bash
image.png

运行服务代码

php server.php

本地镜像phpswoole/swoole:4.5.9-php7.4标签到个人线上仓库18061808047/swoole的default标签

docker tag phpswoole/swoole:4.5.9-php7.4 18061808047/swoole:default
image.png

本地镜像推送到线上

docker push 18061808047/swoole:default
image.png

docker hub仓库:


image.png

相关文章

网友评论

      本文标题:docker for windows 使用swoole并推送到d

      本文链接:https://www.haomeiwen.com/subject/kieuirtx.html