Symfony
sponsored by SensioLabs
Menu
  • About
  • Documentation
  • Screencasts
  • Cloud
  • Certification
  • Community
  • Businesses
  • News
  • Download
  1. Home
  2. Documentation
  3. Setup
  4. Using Docker with Symfony
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud
Search by Algolia

Table of Contents

  • Complete Docker Environment
  • Flex Recipes & Docker Configuration
  • Symfony Binary Web Server and Docker Support

Using Docker with Symfony

Edit this page

Using Docker with Symfony

Can you use Docker with Symfony? Of course! And several tools exist to help, depending on your needs.

Complete Docker Environment

If you'd like a complete Docker environment (i.e. where PHP, web server, database, etc. are all in Docker), check out https://github.com/dunglas/symfony-docker.

Alternatively, you can install PHP on your local machine and use the symfony binary Docker integration. In both cases, you can take advantage of automatic Docker configuration from Symfony Flex.

Flex Recipes & Docker Configuration

The Flex recipe for some packages also include Docker configuration. For example, when you run composer require doctrine (to get symfony/orm-pack), your docker-compose.yml file will automatically be updated to include a database service.

The first time you install a recipe containing Docker config, Flex will ask you if you want to include it. Or, you can set your preference in composer.json, by setting the extra.symfony.docker config to true or false.

Some recipes also include additions to your Dockerfile. To get those changes, you need to already have a Dockerfile at the root of your app with the following code somewhere inside:

1
2
###> recipes ###
###< recipes ###

The recipe will find this section and add the changes inside. If you're using https://github.com/dunglas/symfony-docker, you'll already have this.

After installing the package, rebuild your containers by running:

1
$ docker-compose up --build

Symfony Binary Web Server and Docker Support

If you're using the symfony binary web server (e.g. symfony server:start), then it can automatically detect your Docker services and expose them as environment variables. See Symfony Local Web Server.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
We stand with Ukraine.
Version:

Symfony 6.2 is backed by

Symfony 6.2 is backed by

Check Code Performance in Dev, Test, Staging & Production

Check Code Performance in Dev, Test, Staging & Production

Peruse our complete Symfony & PHP solutions catalog for your web development needs.

Peruse our complete Symfony & PHP solutions catalog for your web development needs.

↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

Avatar of Karel, a Symfony contributor

Thanks Karel (@xwb) for being a Symfony contributor

1 commit • 2 lines changed

View all contributors that help us make Symfony

Become a Symfony contributor

Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

Learn how to contribute

Symfony™ is a trademark of Symfony SAS. All rights reserved.

  • What is Symfony?
    • Symfony at a Glance
    • Symfony Components
    • Case Studies
    • Symfony Releases
    • Security Policy
    • Logo & Screenshots
    • Trademark & Licenses
    • symfony1 Legacy
  • Learn Symfony
    • Symfony Docs
    • Symfony Book
    • Reference
    • Bundles
    • Best Practices
    • Training
    • eLearning Platform
    • Certification
  • Screencasts
    • Learn Symfony
    • Learn PHP
    • Learn JavaScript
    • Learn Drupal
    • Learn RESTful APIs
  • Community
    • SymfonyConnect
    • Support
    • How to be Involved
    • Code of Conduct
    • Events & Meetups
    • Projects using Symfony
    • Downloads Stats
    • Contributors
    • Backers
  • Blog
    • Events & Meetups
    • A week of symfony
    • Case studies
    • Cloud
    • Community
    • Conferences
    • Diversity
    • Documentation
    • Living on the edge
    • Releases
    • Security Advisories
    • SymfonyInsight
    • Twig
    • SensioLabs
  • Services
    • SensioLabs services
    • Train developers
    • Manage your project quality
    • Improve your project performance
    • Host Symfony projects
    Deployed on
Follow Symfony
Search by Algolia