Build a local Virtual Machine (Docker aware) which allows you to run a Symfony full stack application in Ubuntu container on any OS (including Windows/Mac)
- msysgit for Windows user only (see "Get a nice terminal" section below if you don't know how to do)
- VirtualBox
- Docker Machine =>
docker-machine(.exe)
(anddocker-machine-driver-virtualbox(.exe)
since 0.5.0) to move somewhere in yourPATH
A really simple script which uses Docker Machine to build a local Docker aware VM without even installing Docker.
It's also used to set some useful aliases such as drm-all
(which remove all exited containers), drmi-notag
(which remove all untagged images) and docker-compose
(which run Docker Compose in a container), so go check this script and be free to set your own aliases there.
- Miscellaneous useful packages (
make
,vim
,nano
,curl
,wget
,git
,python-software-properties
andsoftware-properties-common
to be able to add PPA) - Nginx with a default site configuration for Symfony app (including HTTPS support)
- PHP 5.6 with FPM and Composer (including php.ini file which is used by both FPM and CLI)
- Ruby 2.2.3 with
bundler
,sass
,less
andcapistrano
- NodeJS 4.x with
nodemon
,pm2
,bower
,gulp
andgrunt
This file (using Docker Compose) will help you to build a perfect environment for your Symfony app by running and linking several containers the way you want using a single command.
Keep in mind that this could also be done using many long docker
commands without the need of docker-compose
at all.
-
Clone this repository in a new folder (let's name it
docker
) at the root of your Symfony application sources, with:git clone https://github.com/Oliboy50/docker-symfony-vm.git docker
-
Go to the new folder
cd docker
and launchdocker-machine-dev
script. After a few seconds you will be given access to the VM where you will be able to rundocker
commands -
Now that you are in your VM, you can "install"
docker-compose
with:install-docker-compose
-
Then, again,
cd
to the new folder in your Symfony project (the VM shared yourC:\Users\
(windows) or/Users/
(mac) folder as/c/Users/
or/Users/
--- see complete reference here) -
Build and run the whole Symfony environment with:
docker-compose-web
(this is just an alias fordocker-compose run --service-ports web
) -
If everything worked you should be able to see your Symfony application running in your host browser at 192.168.99.100 (you can check if it is the correct IP by running
docker-machine ip dev
in your host terminal)
When you want to stop coding, exit
your VM then stop it with docker-machine stop dev
.
# Host terminal
cd C:\Users\mySymfonyApp\docker
docker-machine-dev
# VM terminal
cd /c/Users/mySymfonyApp/docker
docker-compose-web
-
Install
Cmder
http://cmder.net/ (full version with msysgit) -
Configure it to always be ran as an Administrator (right click => Properties, etc.)
-
You may have to define its default terminal type as
{cmd}
instead of{PowerShell}
(because you may experience issues if you use{PowerShell}
terminal)
ProTips:
-
You can set persistent aliases such as
alias cd-project=cd "C:\Users\mySymfonyApp\docker"
=). To view and manage your aliases, edit the file located atC:\cmder_installation_directory\config\aliases
. -
You can dump executable files (such as
docker-machine.exe
) inC:\cmder_installation_directory\bin
then those executables will be automatically accessible in your terminal (i.e.docker-machine
).
This issue comes from your application shared folders, vboxsf
seems to be not powerful enough to handle so many files.
There are currently 2 workarounds for this kind of issue:
- (Recommended) In your application container, copy the
package.json
file to another (not shared) directory. Runnpm install
there. Then copy back thenode_modules
directory to the root of you application.
or
- Run
npm install
on your host machine (it requires you to havenpm
already installed on your host of course).
This issue comes from the 5.x versions of VirtualBox. First, try to update VirtualBox (I don't have this issue on Windows 10 / Docker Machine 0.5.0 / VirtualBox 5.0.10). If you still have this issue with the latest VirtualBox, there are currently 2 workarounds:
- (Recommended) Each time you run
docker-machine-dev
, you'll have to close the VirtualBox warning window.
or
- Installed the last 4.x version of VirtualBox. (I used VirtualBox 4.3.26 when I used Windows 8.1 with Docker Machine 0.3.0)