本地拉取鏡像:
docker pull phpswoole/swoole:4.5.9-php7.4
測試鏡像環(huán)境:
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"
服務(wù)代碼 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
查看所有容器
docker ps -a
進(jìn)入容器
docker exec -it [CONTAINER ID] bash
運行服務(wù)代碼
php server.php
本地鏡像phpswoole/swoole:4.5.9-php7.4
標(biāo)簽到個人線上倉庫18061808047/swoole
的default標(biāo)簽
docker tag phpswoole/swoole:4.5.9-php7.4 18061808047/swoole:default
本地鏡像推送到線上
docker push 18061808047/swoole:default
docker hub倉庫: