Public | Automated Build

Last pushed: 23 days ago
Short Description
A Dockerfile for Symfony Web container: Nginx, PHP-FPM…
Full Description

Docker Symfony

A Dockerfile for Symfony Web container: Nginx, PHP-FPM…

This configuration is built for development. You can use it in production at your own risks !

Docker image

Installation

Install Docker (Boot2docker or Kitematic for OS X & Windows).

Then, run following command to run container:

docker run -d -P btcctb/symfony

Your project is available at http://127.0.0.1 (for Boot2docker, follow http://192.168.59.103).

Configuration

Want to integrate it with MySql ? I recommand to use Docker Compose.

Create docker-compose.yml file as following:

web:
  image: btcctb/symfony
  volumes:
    - .:/var/www
  links: 
    - mysql
  tty: true
  ports:
    - 80:80
mysql:
  image: mysql
  environment:
    MYSQL_DATABASE: symfony
    MYSQL_USER: root
    MYSQL_ALLOW_EMPTY_PASSWORD: 'YES'
  ports:
    - 3306:3306
phpmyadmin:
  image: phpmyadmin/phpmyadmin
  links: 
    - mysql
  environment:
    - PMA_ARBITRARY=1
  restart: always
  ports:
    - 8080:80

Then run docker-compose up -d, your Symfony project is ready to access MySql through 127.0.0.1:3306.

Customize ports

By default, web container run on port 80, mysql container on port 3306. But in some case (for example to prevent ports conflicts on Linux),
you may need to use customize ports.

Let's imagine we'll run Nginx on port 8888, and MySql on port 3386. Update your docker-compose.yml file as following:

web:
  image: btcctb/symfony
  volumes:
    - .:/var/www
  links: 
    - mysql
  tty: true
  ports:
    - 8888:80
mysql:
  image: mysql  
  environment:
    MYSQL_DATABASE: symfony
    MYSQL_USER: root
    MYSQL_ALLOW_EMPTY_PASSWORD: 'YES'
  ports:
    - 3386:3306
phpmyadmin:
  image: phpmyadmin/phpmyadmin
  links: 
    - mysql
  environment:
    - PMA_ARBITRARY=1
  restart: always
  ports:
    - 8080:80
Docker Pull Command
Owner
btcctb
Source Repository

Comments (0)