
Docker for Symfony application, powered by Nginx and php-fpm.
Based on Debian Jessie.
If you are experiencing some issues, take a look at TROUBLESHOOTING
Dockerfile linksImage tags follows PHP versions
latest 8.1 (8.1/Dockerfile)
7 7.4 (7.4/Dockerfile)
8.6-fpm-debian (8.6-fpm-debian/Dockerfile) : PHP 8.6 (official image) on Debian 13 trixie
7.4-trixie (7.4-trixie/Dockerfile) : PHP 7.4 (sury) on Debian 13 trixie
7.1 Not maintained, END OF LIFE
7.0 Not maintained, END OF LIFE
5, 5.6 Not maintained, END OF LIFE
5.4 Not maintained, END OF LIFE
| Symfony | ||||||
|---|---|---|---|---|---|---|
| Image | 2.x | 3.x | 4.x | 5.x | 6.x | |
| 8.1 | :x: | :x: | :heavy_check_mark: (not tested) | :heavy_check_mark: (not tested) | :heavy_check_mark: (not tested) | |
| 8.0 | :x: | :x: | :heavy_check_mark: (not tested) | :heavy_check_mark: (default) | :heavy_check_mark: (not tested) | |
| 7.4 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: (default) | :x: | |
| 7.3 | :heavy_check_mark: (not tested) | :heavy_check_mark: (not tested) | :heavy_check_mark: (default) | :heavy_check_mark: (not tested) | :x: | |
| 7.2 | :heavy_check_mark: (not tested) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: (not tested) | :x: | |
| 7.1 | :heavy_check_mark: (not tested) | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | |
| 7.0 | :heavy_check_mark: (not tested) | :heavy_check_mark: (not tested) | :x: | :x: | :x: | |
| 5.6 | :heavy_check_mark: (not tested) | :heavy_check_mark: (not tested) | :x: | :x: | :x: |
Composer versions :
docker pull kibatic/symfony
Then run in your symfony folder
# Image >= 7.3 & Symfony 2.x, 3.x
docker run -e SYMFONY_VERSION=3 -v $(pwd):/var/www -p 8080:80 kibatic/symfony:7.3
# Image >= 7.3 & Symfony 4.x
docker run -v $(pwd):/var/www -p 8080:80 kibatic/symfony:7.3
# Image < 7.3 & Symfony 2.x, 3.x
docker run -v $(pwd):/var/www -p 8080:80 kibatic/symfony:7.2
# Image < 7.3 & Symfony 4.x
docker run -e SYMFONY_VERSION=4 -v $(pwd):/var/www -p 8080:80 kibatic/symfony:7.2
Symfony app will be accessible on http://localhost:8080/
Add the following vars in the docker-compose file :
web:
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
Then to enable or disalble blackfire :
# enable blackfire
docker compose exec -T web /enable-blackfire.sh --on
# disable blackfire
docker compose exec -T web /enable-blackfire.sh --off
In our project, we use a Makefile to simplify the commands (from the container or from the host) :
_enable-blackfire: ## enable blackfire
/enable-blackfire.sh --on
enable-blackfire: ## enable blackfire
docker compose exec -T web make _enable-blackfire
_disable-blackfire: ## disable blackfire
/enable-blackfire.sh --off
disable-blackfire: ## disable blackfire
docker compose exec -T web make _disable-blackfire
If you want to replace the default nginx settings, overwrite configuration file at /etc/nginx/sites-enabled/default.
COPY nginx.conf /etc/nginx/sites-enabled/default
You may also want to add only some directives in existing site config.
COPY custom-config.conf /etc/nginx/conf.d/docker/custom-config.conf
For both production and dev environment you should log to stdout / stderr, example below.
# config/packages/monolog.yaml
monolog:
handlers:
stdout:
type: stream
path: 'php://stdout'
level: debug
channels: ['!event']
# (Optional) format logs to json
#formatter: monolog.formatter.json
stderr:
type: stream
path: 'php://stderr'
level: error
# (Optional) format logs to json
#formatter: monolog.formatter.json
A common practice is to log to stdout, but there are major bug in php-fpm wich makes stdout logging not reliable :
This image setup a known workaround (see here) and expose a log stream as env var LOG_STREAM, but you cannot log to stdout For a proper logging you have to configure monolog to log to this stream
# app/config_dev.yml
monolog:
handlers:
main:
type: stream
path: '/tmp/stdout'
level: debug
You can also use symfony %env(LOG_STREAM)% if your symfony version is compatible with this syntax
We also provide a default dirty solution for standard monolog configuration, this is not recommended in production
tail -q -n 0 -F app/logs/dev.log app/logs/prod.log var/logs/dev.log var/logs/prod.log
Content type
Image
Digest
sha256:75fb46008…
Size
249.9 MB
Last updated
7 days ago
docker pull kibatic/symfony