Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🐳 A docker multicontainer with NGINX, PHP7-FPM, MySQL,MailCatcher and ELK (Elasticsearch Logstash and Kibana) 🐳

License

NotificationsYou must be signed in to change notification settings

prakasha4devops/symfony-docker

Repository files navigation

(PHP7-FPM - NGINX - MySQL - ELK - PHPMYADMIN - MAILCATCHER - REDIS)

Build Status

Docker-symfony gives you everything you need for developing Symfony application. This complete stack run with docker anddocker-compose (1.7 or higher).

Installation

  1. Create a.env from the.env.dist file. Adapt it according to your symfony application

    cp .env.dist .env
  2. Build/run containers with (with and without detached mode)

    $ docker-compose build$ docker-compose up -d$ docker-compose up -d --build
  3. Update your system host file (add symfony.dev)

    # UNIX only: get containers IP address and update host (replace IP according to your configuration)$ docker network inspect bridge| grep Gateway# unix only (on Windows, edit C:\Windows\System32\drivers\etc\hosts)$ sudoecho"171.17.0.1 symfony.dev">> /etc/hostsOR$ sudoecho"127.0.0.1  symfony.dev">> /etc/hosts

    Note: ForOS X, please take a lookhere and forWindows readthis (4th step).

  4. Prepare Symfony app

    1. Update app/config/parameters.yml

      # path/to/your/symfony-project/app/config/parameters.ymlparameters:database_host:db
    2. Composer install & create database

      $ docker-composeexec php bash$ composer install# Symfony2$ sf doctrine:database:create$ sf doctrine:schema:update --force$ sf doctrine:fixtures:load --no-interaction# Symfony3$ sf3 doctrine:database:create$ sf3 doctrine:schema:update --force$ sf3 doctrine:fixtures:load --no-interaction
  5. Enjoy :-)

Usage

Just rundocker-compose up -d, then:

## Customize

If you want to add optionnals containers like Redis, PHPMyAdmin... take a look ondoc/custom.md.

How it works?

Have a look at thedocker-compose.yml file, here are thedocker-compose built images:

  • db: This is the MySQL database container,
  • php: This is the PHP-FPM container in which the application volume is mounted,
  • nginx: This is the Nginx webserver container in which application volume is mounted too,
  • elk: This is a ELK stack container which uses Logstash to collect logs, send them into Elasticsearch and visualize them with Kibana.

This results in the following running containers:

$ docker ps -a OR$ docker-compose ps            Name                          Command               State                       Ports --------------------------------------------------------------------------------------------------------------------- dockersymfony_db_1            docker-entrypoint.sh mysqld      Up      0.0.0.0:3306->3306/tcp dockersymfony_elk_1           /usr/bin/supervisord -n -c ...   Up      0.0.0.0:81->80/tcp dockersymfony_mailcatcher_1   /run.sh                          Up      0.0.0.0:1025->1025/tcp, 0.0.0.0:1080->1080/tcp dockersymfony_nginx_1         nginx                            Up      443/tcp, 0.0.0.0:80->80/tcp dockersymfony_php_1           docker-php-entrypoint php-fpm    Up      0.0.0.0:9000->9000/tcp dockersymfony_phpmyadmin_1    /run.sh phpmyadmin               Up      0.0.0.0:8080->80/tcp

Useful commands

# bash commands$ docker-composeexec php bash# Composer (e.g. composer update)$ docker-composeexec php composer update# SF commands (Tips: there is an alias inside php container)$ docker-composeexec php php /var/www/symfony/app/console cache:clear# Symfony2$ docker-composeexec php php /var/www/symfony/bin/console cache:clear# Symfony3# Same command by using alias$ docker-composeexec php bash$ sf cache:clear# Retrieve an IP Address (here for the nginx container)$ docker inspect --format'{{ .NetworkSettings.Networks.dockersymfony_default.IPAddress }}'$(docker ps -f name=nginx -q)172.18.0.4$ docker inspect$(docker ps -f name=nginx -q)| grep IPAddress# MySQL commands$ docker-composeexec db mysql -uroot -p"root"# F***ing cache/logs folder$ sudo chmod -R 777 app/cache app/logs# Symfony2$ sudo chmod -R 777 var/cache var/logs# Symfony3# Check CPU consumption$ docker stats$(docker inspect -f"{{ .Name }}"$(docker ps -q))# Delete all containers$ docker rm -f$(docker ps -aq)# Delete all images$ docker rmi$(docker images -q)# Restarting all running docker containers$ docker restart$(docker ps -aq)# docker restart$ docker-compose restartOR# Recreating docker$ docker-compose up -d# stop docker$ docker-compose stop $ docker stop$(docker ps -a -q)# remove all of Docker containers$ docker rm$(docker ps -a -q)# docker usage$ docker ps -s

Mailcatcher

php -r 'mail("test@test.com", "test1", "test1");';

FAQ

  • Got this error:ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. ?
    Rundocker-compose up -d instead.

  • Permission problem? Seethis doc (Setting up Permission)

  • How to config Xdebug?Xdebug is configured out of the box!Just config your IDE to connect port9001 and id keyPHPSTORM

Contributing

First of all,thank you for contributing ♥

About

🐳 A docker multicontainer with NGINX, PHP7-FPM, MySQL,MailCatcher and ELK (Elasticsearch Logstash and Kibana) 🐳

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp