Skip to main content

Symfony with Docker

Symfony CLI provides a Docker integration that allows you to run your Symfony application with Docker containers.

Prerequisites​

To use the Symfony Docker integration, you need to have Docker installed on your machine. You can download Docker from https://www.docker.com/get-started.

Docker compose file​

Symfony CLI creates a docker-compose.yaml and a docker-compose.override.yaml file in the .symfony directory of your project. These files are used to configure the Docker containers.

The docker-compose.yaml file contains the base configuration for the Docker containers. The docker-compose.override.yaml file contains the configuration that is specific to your project. Symfony CLI updates this file when you run the docker:compose command.

Docker and Environment Variables​

Symfony CLI detects environment variables from Docker containers and makes them available to your application (Only for a specific list of services :

  • MySQL
  • PostgreSQL
  • Redis
  • Memcached
  • RabbitMQ
  • Elasticsearch
  • MongoDB
  • Kafka
  • MailCatcher
  • Blackfire
  • Mercure

Create a Docker Database Container​

To create a Docker database container, run the following command:

symfony console make:docker:database

Open web management interfaces​

You can open the web management interfaces for that expose a web interface by running the following command:

symfony open:local:webmail
symfony open:local:rabbitmq

Run a PSQL command​

You can run a PSQL command by running the following command:

symfony run psql