docker multi project development environment

docker vhostalias setup for a multi project development environment

Often Docker is used on a per project case. Which is great when you have a specific configuration for a project. It's probably also the way you should go when you want to mimic exactly the production environment or when you want to use the docker container itself also for the production environment.

But what if you want a good development setup but don't need a specific docker setup for the projects running on it. That can be the case with study projects, or smaller projects which are less critical on the configuration and/or simulation of the (production) environment.

In that case it might be more efficient to have one docker development setup where you can run multiple projects in. Some advantages of it:

  • You don't have to maintain several different docker projects
  • You don't need a local development setup because it's all in your docker setup
  • Because your development stack is in docker, it's faster to setup on another machine
  • Easier to switch or work at the same time on multiple projects. No need to switch of another container or configure several different ports

And it's quite easy to build. The vhost alias that you might have used in an earlier local development environment can do the same job in docker.
So if your hostname is myproject123 it will go to some directory myproject123/webroot.

On top of that you can add some other php modules and settings for a nice development environment.
At this moment I added xdebug and php code sniffer together with some instructions in the README how to use them and to set them up with phpstorm.

https://github.com/FlorisVedder/docker-dev-multi-project

So with this setup you can create a new directory for your project in the projects directory. So like the example project:
http://web:8001/
Which is on your host system located on:
projects/web/webroot
When you create your own project it will be:
http://yourprojectname:8001/
And:
projects/yourprojectname/webroot
Don't forget to point yourprojectname to dockers ip in the hosts file of your local machine, for further instructions check the README.