easyswoole-docker
April 11, 2024 · View on GitHub
English | 中文
easyswoole-docker
Develop in Docker
If your native environment does not meet the EasySwoole system requirements, or if you are unfamiliar with system configuration, you can run and develop the EasySwoole project as follows using Docker.
Run Container
In the following example the host will be mapped to the local directory /workspace/project:
If
the selinux-enabledoption is enabled when docker starts, access to host resources in the container will be restricted, so you should add the--privileged -u rootoption when starting the container.
docker run --name easyswoole \
-v /workspace/project:/var/www/project \
-p 9501:9501 -it \
--privileged -u root \
--entrypoint /bin/sh \
easyswoolexuesi2021/easyswoole:php8.2.17-alpine3.19-swoole5.1.1
The public images you can choose from:
php 7.3
easyswoolexuesi2021/easyswoole:php7.3.33-alpine3.12-swoole4.4.26
php 7.4
easyswoolexuesi2021/easyswoole:php7.4.33-alpine3.15-swoole4.4.26
php 8.1
easyswoolexuesi2021/easyswoole:php8.1.22-alpine3.16-swoole4.8.13easyswoolexuesi2021/easyswoole:php8.1.22-alpine3.16-swoole5.1.1easyswoolexuesi2021/easyswoole:php8.1.27-alpine3.18-swoole4.8.13easyswoolexuesi2021/easyswoole:php8.1.27-alpine3.18-swoole5.1.1
php 8.2
easyswoolexuesi2021/easyswoole:php8.2.8-alpine3.18-swoole4.8.13easyswoolexuesi2021/easyswoole:php8.2.8-alpine3.18-swoole5.1.1easyswoolexuesi2021/easyswoole:php8.2.14-alpine3.19-swoole4.8.13easyswoolexuesi2021/easyswoole:php8.2.14-alpine3.19-swoole5.1.1easyswoolexuesi2021/easyswoole:php8.2.17-alpine3.19-swoole4.8.13easyswoolexuesi2021/easyswoole:php8.2.17-alpine3.19-swoole5.1.1
php 8.3
easyswoolexuesi2021/easyswoole:php8.3.4-alpine3.19-swoole5.1.2
Create Project
cd /var/www/project
composer require easyswoole/easyswoole
php vendor/bin/easyswoole.php install
# php vendor/bin/easyswoole install # When the EasySwoole framework version in your project is less than 3.7.1.
In some environments, such as the
Dockerenvironment of theWin10system. Virtual machine shared directory cannot be used as theTempdirectory of theEasySwooleframework, as it will not be able to create sockets due to insufficient permissions. This will result in an error message:listen xxxxx.lock fail. To do so, you can manually setTEMP_DIRin thedev.phpconfiguration file, Change the DIR directory to a different path, such as'/tmp'.
Start the project
cd /var/www/project
php easyswoole.php server start
# php easyswoole server start # When the EasySwoole framework version in your project is less than 3.7.1.
Next, you can see your installed project in /var/www/project. Since EasySwoole is a persistent CLI framework, when you have modified your code, you should terminate the running process instance with CTRL + C and re-execute the php easyswoole server start start startup command to restart your server and reload the code.
Supported tags and respective Dockerfile links
tag format:
- 7.4: php version, support 7.3/7.4/8.1/8.2, Recommend 7.4
- 3.12: alpine version, support alpine 3.12/3.15/3.16/3.18, recommend 3.15
- 4.4.26: swoole version
support:
php 7.3.33
php 7.4.33
php 8.1.27
php 8.2.17
php 8.3.4
Quick reference
How to use this image
Added Dockerfile to your project.
Info
Base image contains extensions below:
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
gd
hash
iconv
igbinary
json
libxml
mbstring
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
standard
swoole
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache