dockerfile/README.md
2022-10-20 06:39:57 +00:00

107 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## docker 安装
### windows & mac|linux
mac|linux桌面端可以直接安装docker桌面客户端win10可以先安装wsl2再安装docker桌面客户端, 19年的时候我用过win10安装docker桌面客户端可以不需要wsl但必须启动虚拟机服务不过这边建议使用wsl2因为比虚拟机体验更好
安装教程参考
1. [docker for win 安装](https://www.runoob.com/docker/windows-docker-install.html)
2. [wsl2安装教程](https://learn.microsoft.com/zh-cn/windows/wsl/install)
## 使用
```
# 进入需要构建目标镜像目录比如:
cd php8.1-swoole-alpine
# 构建镜像命令
docker build -t [自定义镜像名称] .
# 生成容器 指定容器名称
docker run --name="php_swoole_runtime" -p 9501:9501 -d [镜像名称]
# 进入容器
docker exec -it [容器名称] /bin/sh
# composer加速
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# 安装hyperf
composer create-project hyperf/hyperf-skeleton
# 运行
cd hyperf-skeleton/
php bin/hyperf.php start
#访问127.0.0.1:9501 即可
```
## 命令参考
[docker run 命令参考](https://www.runoob.com/docker/docker-run-command.html)
## 镜像安装扩展如下:
镜像同时支持fpm&swoole两种运行环境如果镜像内想用git请执行`apk add git ` 即可,已安装扩展如下:
```
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
event
exif
fileinfo
filter
ftp
gd
hash
iconv
igbinary
imagick
json
libxml
mbstring
mongodb
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
protobuf
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
swoole
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
```