Run Symfony framework using PHP:8.4-fpm.
1.0K
A Dockerized Symfony application using PHP 8.4 (via php:8.4-alpine) and Nginx (via nginx:alpine). This setup is ideal for local development, testing, and production environments. The container comes with: bash, nano, curl and compose packages, so you can use them directly in the container terminal. You can install Symfony CLI and Composer in your host machine if you want to install some packages in your project.
A lightweight Docker image combining PHP 8.4 (php:8.4-alpine) and Nginx (nginx:alpine) for running a latest version of Symfony PHP applications. Perfect for local development, testing, or production environments.
/etc/nginx/conf.d for easy user customization./var/www/html/public/var/www/html.The architectures supported by this image are:
| Architecture | Available | Tag |
|---|---|---|
| x86-64 | ✅ | amd64-<version tag> |
| arm64 | ✅ | arm64v8-<version tag> |
This is the description of the Docker Compose file configuration.
[!NOTE]
PHP_SERVICE_NAMEmust be the same asphp service name. You must usehttps://xx.xx.xx.xx:8043to access your project if you need the Symfony Web Debug Toolbar.
You can also put your project (The Port you used to Bind to Port 80) under a Reverse Proxy, you can use Nginx Proxy Manager.
| 📌 Ports | 📚 Description |
|---|---|
8008 | Bind Port 80: Symfony Web Debug Toolbar Not Loading |
8043 | Bind Port 443: Symfony Web Debug Toolbar loads correctly |
| 🏷️ Environment | 📚 Description |
PGID | Process Group ID, Linux command: id |
PUID | Process User ID, Linux command: id |
PHP_SERVICE_NAME | His value must be the same as the php service name in your Docker Compose file |
| 📁 Volume | 📚 Description |
./path/to/web/conf | Mount Nginx configuration folder: /etc/nginx/conf.d |
./path/to/web/html | Mount symfony framework folder: /var/www/html |
To help you get started creating a container from this image you can either use docker-compose or the docker cli. The easy way is to follow this steps:
git clone https://github.com/kprimecity/docker-symfony.git,cd docker-symfonysudo nano docker-compose.yaml,sudo docker compose up --wait -d to set up and start a fresh Symfony project,php container log to see the progress,https://localhost:8043 in your favorite web browser to access your project,localhost by your local ip address.git clone https://github.com/kprimecity/docker-symfony.git
cd docker-symfony
sudo nano docker-compose.yaml
[!NOTE] Modify the Docker Compose file before running it; so you can adjust your containers (Nginx and PHP) according to your needs. Run the containers using:
sudo docker compose up --wait -d. Wait a few minutes for the Symfony framework to be downloaded.
Docker compose file:
name: docker-symfony
services:
nginx-8008: # Your Nginx service name
image: kprimecity/docker-symfony-nginx:latest
container_name: docker-symfony-nginx-8008 # Your Container name
restart: unless-stopped
environment:
- PGID=1000
- PUID=1000
- PHP_SERVICE_NAME=php-8008 # This Value MUST be as the php service name bellow
ports:
- 8008:80 # Bind Port 80: Symfony Web Debug Toolbar Not Loading
- 8043:443 # Bind Port 443: Symfony Web Debug Toolbar loads Correctly
volumes:
- ./path/to/web/conf/8008:/etc/nginx/conf.d # Mount Nginx config
depends_on:
- php-8008 # Same as PHP_SERVICE_NAME environment and php service name bellow
networks:
- docker-symfony-network
php-8008: # PHP service name: Same as PHP_SERVICE_NAME environment ABOVE
image: kprimecity/docker-symfony-php:latest
container_name: docker-symfony-php-8008 # Your Container name
restart: unless-stopped
environment:
- PGID=1000
- PUID=1000
volumes:
- ./path/to/web/html:/var/www/html # Mount html content to manage your project locally
networks:
- docker-symfony-network
networks:
docker-symfony-network:
name: docker-symfony-network
driver: bridge
default:
name: docker-symfony_default
Docker Run command:
docker network create -d bridge docker-symfony-network \
docker network create docker-symfony_default \
docker run --net docker-symfony-network \
--name docker-symfony-nginx-8008 \
--restart unless-stopped
-e PGID=1000 \
-e PUID=1000 \
-e PHP_SERVICE_NAME=php-8008 \
-p 8008:80 \
-p 8043:443 \
-v ./path/to/web/conf/8008:/etc/nginx/conf.d \
kprimecity/docker-symfony-nginx:latest \
docker run --net docker-symfony-network \
--name docker-symfony-php-8008 \
--restart unless-stopped \
-e PGID=1000 \
-e PUID=1000 \
-v ./path/to/web/html:/var/www/html \
kprimecity/docker-symfony-php:latest
sudo docker compose up --wait -d
[!NOTE] This command will build all Docker images and run all containers.
After running the container, access your application in your browser:
https://localhost:8043
You should see your index page rendered by the docker-symfony Nginx and PHP-FPM containers.
[!NOTE] No need to start the
Symfony serverto access your project.
The Port you used to Bind to Port 80) under a Reverse Proxy, you can use Nginx Proxy Manager,nginx server configuration to make Nginx use your own SSL.PHP_SERVICE_NAME) value must be as the php container service name.http://xx.xx.xx.xx:8008 (No Symfony Web Debug Toolbar) or https://xx.xx.xx.xx:8043 (With Symfony Web Debug Toolbar).git checkout -b feature/your-feature).git commit -m "Add your feature").git push origin feature/your-feature).This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
Take care! 💖
Content type
Image
Digest
sha256:4b0093877…
Size
55.3 MB
Last updated
about 1 year ago
docker pull kprimecity/docker-symfony-php