
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
https://travis-ci.org/kibatic/symfony-docker.svg?branch=master](https://travis-ci.org/kibatic/symfony-docker) https://images.microbadger.com/badges/image/kibatic/symfony:latest.svg](https://microbadger.com/images/kibatic/symfony:latest "获取您自己的镜像徽章") https://images.microbadger.com/badges/version/kibatic/symfony:latest.svg](https://microbadger.com/images/kibatic/symfony:latest "获取您自己的版本徽章")
用于Symfony应用的Docker镜像,由Nginx和php-fpm提供支持。
基于Debian Jessie。
如果遇到问题,请查看TROUBLESHOOTING
Dockerfile链接镜像标签遵循PHP版本
latest 8.1 https://github.com/kibatic/symfony-docker/blob/master/8.1/Dockerfile
8.0 https://github.com/kibatic/symfony-docker/blob/master/8.0/Dockerfile
7 7.4 https://github.com/kibatic/symfony-docker/blob/master/7.4/Dockerfile
7.3 https://github.com/kibatic/symfony-docker/blob/master/7.3/Dockerfile
7.2 https://github.com/kibatic/symfony-docker/blob/master/7.2/Dockerfile
7.1 不再维护,已终止支持
7.0 不再维护,已终止支持
5, 5.6 不再维护,已终止支持
5.4 不再维护,已终止支持
| Symfony | |||||
|---|---|---|---|---|---|
| 镜像 | 2.x | 3.x | 4.x | 5.x | |
| 8.1 | ❌ | ❌ | ✅(未测试) | ✅(未测试) | |
| 8.0 | ❌ | ❌ | ✅(未测试) | ✅(默认) | |
| 7.4 | ❌ | ❌ | ✅ | ✅(默认) | |
| 7.3 | ✅(未测试) | ✅(未测试) | ✅(默认) | ✅(未测试) | |
| 7.2 | ✅(未测试) | ✅ | ✅ | ✅(未测试) | |
| 7.1 | ✅(未测试) | ✅ | ✅ | ❌ | |
| 7.0 | ✅(未测试) | ✅(未测试) | ❌ | ❌ | |
| 5.6 | ✅(未测试) | ✅(未测试) | ❌ | ❌ |
Composer版本:
bashdocker pull docker.xuanyuan.run/kibatic/symfony
然后在您的Symfony文件夹中运行:
bash# 镜像 >= 7.3 且 Symfony 2.x、3.x docker run -e SYMFONY_VERSION=3 -v $(pwd):/var/www -p 8080:80 docker.xuanyuan.run/kibatic/symfony:7.3 # 镜像 >= 7.3 且 Symfony 4.x docker run -v $(pwd):/var/www -p 8080:80 docker.xuanyuan.run/kibatic/symfony:7.3 # 镜像 < 7.3 且 Symfony 2.x、3.x docker run -v $(pwd):/var/www -p 8080:80 docker.xuanyuan.run/kibatic/symfony:7.2 # 镜像 < 7.3 且 Symfony 4.x docker run -e SYMFONY_VERSION=4 -v $(pwd):/var/www -p 8080:80 docker.xuanyuan.run/kibatic/symfony:7.2
Symfony应用将可通过 http://localhost:8080/ 访问
在docker-compose文件中添加以下环境变量:
yamlweb: build: . volumes: - .:/var/www environment: PERFORMANCE_OPTIM: "false" BLACKFIRE_SERVER_ID: 3xxxx-xxxxx-xxxxxx-xxxxxxx-xxc BLACKFIRE_SERVER_TOKEN: 5d6cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc47fb BLACKFIRE_CLIENT_ID: 8exxxxx-xxx-xxxxx-xxxxxx-xx5 BLACKFIRE_CLIENT_TOKEN: 6caaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx012
启用或禁用Blackfire:
bash# 启用Blackfire docker compose exec -T web /enable-blackfire.sh --on # 禁用Blackfire docker compose exec -T web /enable-blackfire.sh --off
在项目中,可使用Makefile简化命令(从容器或主机):
makefile_enable-blackfire: ## 启用blackfire /enable-blackfire.sh --on enable-blackfire: ## 启用blackfire docker compose exec -T web make _enable-blackfire _disable-blackfire: ## 禁用blackfire /enable-blackfire.sh --off disable-blackfire: ## 禁用blackfire docker compose exec -T web make _disable-blackfire
若要替换默认Nginx设置,覆盖/etc/nginx/sites-enabled/default配置文件:
dockerfileCOPY nginx.conf /etc/nginx/sites-enabled/default
您也可以仅添加一些指令到现有站点配置:
dockerfileCOPY custom-config.conf /etc/nginx/conf.d/docker/custom-config.conf
对于生产和开发环境,建议记录到stdout/stderr,示例如下:
yaml# config/packages/monolog.yaml monolog: handlers: stdout: type: stream path: 'php://stdout' level: debug channels: ['!event'] # (可选)将日志格式化为JSON #formatter: monolog.formatter.json stderr: type: stream path: 'php://stderr' level: error # (可选)将日志格式化为JSON #formatter: monolog.formatter.json
常见做法是记录到stdout,但php-fpm存在重大bug导致stdout日志不可靠:
此镜像设置了已知的解决方法(https://github.com/docker-library/php/issues/207),并通过环境变量**LOG_STREAM**暴露日志流,但**不能记录到stdout**。为了正确记录日志,必须配置Monolog记录到此流:
yaml# app/config_dev.yml monolog: handlers: main: type: stream path: '/tmp/stdout' level: debug
如果您的Symfony版本兼容此语法,也可以使用Symfony %env(LOG_STREAM)%。
我们还为标准Monolog配置提供了默认的临时解决方案,不建议在生产环境中使用:
bashtail -q -n 0 -F app/logs/dev.log app/logs/prod.log var/logs/dev.log var/logs/prod.log
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 kibatic/symfony 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: