构建开发镜像:
包含 composer + xdebug
cd php\php74xc\
docker build --pull --rm -f "Dockerfile" -t jianboy/php74xc:latest
cd php\php8xc\
docker build --pull --rm -f "Dockerfile" -t jianboy/php8xc:latest
# 切换 php 版本
cd workspace
chmod -R 777 .
docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 jianboy/php74xc:latest /bin/bash
docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 jianboy/php8xc:latest /bin/bash
composer install
docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8112:8112 sineverba/php74xc:1.11.0 php -S 0.0.0.0:8112
curl 127.0.0.1:8112
php基础镜像:
chmod -R 777 .
docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:8.3.6-apache
docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -v $(pwd)/Downloads:/root/Downloads/MusicDL/ -p 9000:80 php:8.1.8-apache /bin/bash
thinkphp new demo
thinkphp serve
# 其他版本
docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:7.4.27-apache
docker run --rm -it -v $(pwd):/var/www/html -p 9000:80 php:5.6.38-apache
开发环境需要 composer,启动下面容器即可:
# php8+xdebug+composer
docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 sineverba/php8xc:1.18.0 /bin/bash
docker run --rm -it -w /var/www/html -v $(pwd):/var/www/html -p 8000:8000 sineverba/php74xc:1.11.0 /bin/bash
laravel 项目使用下面容器,可以添加 docker-compose.yaml
配置一并启动数据库:
# https://hub.docker.com/r/bitnami/laravel
docker run --rm -it -v $(pwd):/app -p 8000:8000 bitnami/laravel:latest
docker run -d --name laravel \
-p 8000:8000 \
--env DB_HOST=mariadb \
--env DB_PORT=3306 \
--env DB_USERNAME=bn_myapp \
--env DB_DATABASE=bitnami_myapp \
--network laravel-network \
--volume ${PWD}/my-project:/app \
bitnami/laravel:latest
安装 composer
docker run --rm -it -v /workspace:/app composer:latest /bin/bash
基于 docker-compose,启动 mysql, adminer, redis等等
docker-compose up -d
参考 template 代码即可
docker run --rm -it -v /workspace:/app swoole:latest /bin/bash
docker run --rm -it -v /workspace:/app composer:latest /bin/bash
composer create-project --prefer-dist laravel/laravel blog
docker run --rm -it -v /workspace:/app composer:latest /bin/bash
composer create-project topthink/think demo
docker run --rm -it -v /workspace:/app composer:latest /bin/bash
composer create-project --prefer-dist yiisoft/yii2-app-basic demo
docker run --rm -it -w /app -v ${PWD}:/app jujhars13/docker-node-apidocjs /bin/bash
apidoc -i . -o doc
docker run --rm \
-v ${PWD}:/app \
jujhars13/docker-node-apidocjs \
apidoc -i api.superwidgets.com/ -o html/public -t template
通过docker快速启动一个测试数据库: