Dockervel: A Laravel development environment in Docker

A complete Laravel development environment in Docker Containers:

  • Bring Up a Laravel development environment with a single command easy as dup
  • Execute Artisan commands easy as dartisan make:auth
  • Run Composer command easy as dcomposer update
  • Run NodeJS script easy as dnodejs npm install
  • Run gulp watch easy as dgulp-watch
  • Containers managed with docker-compose
  • Lightweight as it is mostly based in Linux Alpine base image of 5MB.

Containers included

  • Nginx 1.8.0 & PHP 5.6 running in Alpine
  • MariaDB 5.5 running in Alpine
  • Redis running in Alpine
  • Composer PHP running in Alpine.
  • Artisan running in Debian (alpine is missing some PHP packages)
  • NodeJS with gulp, grunt and bower -g installed in official node:4.2.2-slim base image
  • Volumes mounted as containers


Make sure you have docker and docker-compose installed. See here for installing them
  • clone this repo: git clone
  • cd in: cd dockervel
  • run as su: su
  • add aliases: . ./
  • run: dup and you have a server running! Hit localhost in your browser and you will see nginx fault message becasuse there is no www/public/index.php.
  • create new Laravel project: dcomposer-create
  • fix permissions: dpermit
  • change .env: see below for options
  • run artisan commands: dartisan make:auth
  • fix permissions: dpermit Now you have a registration system active. Go to localhost and register a new user to see that db's are running ok.
  • npm install: dnodejs npm install
  • gulp install: dnodejs gulp install
  • gulp watch: dulp-watch Now there is one container running gulp watch and monitors changes on files according your gulpfile.js

aliases contains shortcuts to common commands. run dot space dot / to activate aliases for this terminal session.
$ . ./
and now for this terminal session you have aliases like dartisan, dcomposer, dnodejs, dup, dstop.
If you don't want to work with aliases, open the script and see the coressponding commands next to each alias. In the following document it is supposed that you have executed as su and you have the aliases active.

Create new Laravel Project

  • create new laravel project: dcomposer-create
  • type localhost in your browser and you see the Laravel welcome screen

Fix permitions

since containers have different user in them, you have to change the permisions in www/ folder to be able to write. type:
$ dpermit
it will simply chmod -R 777 www Remember to run dpermit after each time the www folder has a new file.

Configure Laravel for mysql

change DB_HOST in .env to point to mysql. This is the name that it is used in docker-compose.yml (link: -mysql:mysql)

Configure Laravel for redis

change REDIS_HOST in .env to point to predis. This is the name that it is used in docker-compose.yml (link: -redis:predis).

in Laravel 5.2 there are some issues with redis namespace, so to avoid conflicts predis is used. Also you have to change /config/app.php, and replace:
'Redis'     => Illuminate\Support\Facades\Redis::class,
'LaravelRedis'     => Illuminate\Support\Facades\Redis::class,
Use it like:
$redis= LaravelRedis::connection();
$redis->set('name', 'myname');

Running Artisan commands

type dartisan followed by an artisan command
$ dartisan make:auth
$ dartisan migrate
$ dartisan tinker

Running composer commands

type dcomposer followed by a composer command
$ dcomposer update
$ dcomposer require predis/predis


to install node modules in your project run
$ dnodejs npm install


install gulp with:
dnodejs gulp install:
run gulp once:
add gulp watch:


The size of images is about 750 MB:
* front:     70.05 MB
* mysql:    199.50 MB
* redis:      8.50 MB
* composer: 236.80 MB
* nodejs:    36.09 MB
* artisan   208.80 MB
The base memory usage for the containers of the server running is about 110 MB.
* front: 18 MB
* mysql: 97 MB
* redis:  1 MB


Thanx to:


  1. Nice work Man, I was working on something similar over the weekend.

  2. Nice work Man, I was working on something similar over the weekend.

    1. Glad i've helped. I'm working on adding PHP Unit right now, keep in touch.

  3. I'd prefer to install the images via Docker Hub instead of using git clone. Would you make images there?

    1. From GitHub you get only the docker-compose-yml(and asistant files). All images are pulled from Docker Hub.

  4. Hi there,
    thanks for the setup. Actually I started and tried to install the debug bar (which requires php-iconv), how do I add custom APK packages to the docker instance?

    thank you


    1. Hi Simom,
      Nice remark about debug bar. I've updated Dockervel so that it supports iconv. Update your local repository and you are ready. Try it out and let me now if it is ok.

      You can add packages to the docker instace by adding them to the docker file.
      See related commit here
      Now change the docker-composer.yml to link to the new image. see related commit here.
      Learn more about automated builds from github to dockerhub here

  5. Or you can try a much better solution like LaraDock

  6. I need help. I can't find the .env to make changes.
    Or I have to make the env changes in the docker-compose.yml file

    1. .env file is part of you laravel project. It is located at the root of your laravel project. As a "." file it is hidden by default in your file browser. Try to enable the "show hidden files" on your file browser.

  7. I need some suggestion . Well I have to make a laravel app using Behat(software for BDD ). Is there any way I can use Behat in this environment?

    1. I'm not familiar with Behat but i think that you can install it with `dcomposer require --dev behat/behat=~3.0.4` . A solution to run it from a container might be something like creating dartisan similar dockerfile, remove the entrypoint and use it like a php container. If you added in your docker-compose.yml for example you could call it like `docker-compose run dbehat behat --init`.
      Hope that i've helped

    2. Can you help further on the above question? I happen to want to do the same thing. I installed behat with composer.
      I added in the docker-compose.yml:
      image: tvial/behat
      - ./www:/var/www
      - back-tier
      And I get
      ERROR: for behat No command specified
      I then tried to run:
      docker-compose run www/vendor/behat/behat/bin/behat
      (it's the path to behat) and got
      ERROR: No such service: www/vendor/behat/behat/bin/behat
      Any help appreciated

  8. This comment has been removed by the author.

  9. I have gone true the installation ,it's seemed ok. When I run dartisan serve and visit localhost ="The site can't be reached"
    In /var/www/ I have one laravel project that I used to load running also the localhost. What can I change to make this work? In hosts file I have for the use of previous laravel proj. endited this .
    I'm sorry if the questions are dumb but I'm a newbie.

    1. 1) if you have another web server running, like WAMP, you should stop it because they are trying to use the same ip.
      2) dont forget to change the permitions to www with `dpermit`
      Hope that one of both will do the work

  10. Can like run something like this
    php -S localhost:8888 -t public
    in this container?

    1. If you want to change the port, change it through `docker-compose.yml` and `port: 8888:80`.

  11. I have this docker image pulled ,and worked something on the app ,made some changes and I want to send it to my friend like a docker image. But I'm not sure how to make a dockerfile ,using your dockervel as base .Can you advice me how to put it together?

    1. hmm.. First of all, dockervel is not a single image. It consists of sevelar images orchestrated together by docker-compose (see docker-compose.yml). And the reason for that is that you don't need all the parts every time (eg. you don't load nodejs when all you want is to work with artisan). Also you can change parts (eg. you can change MySQL with Postgres).
      If you want to share your project, the easy way is to share the entire dockervel folder (please omit the node_modules folder, you can recreate it with `dcomposer install`).
      If you realy want to make it a single dockerfile (not so good idea) you should combine each dockerfile into a single one and you will end up with a huge and not flexible container.
      You could also try a docker-in-docker, but maybe first read this

  12. This comment has been removed by the author.

  13. I read that Post and got it fine and informative. Please share more like that...Great Article it its really informative and innovative keep here:
    web design | laravel development

  14. This comment has been removed by a blog administrator.

  15. Valuable post useful for everyone.Keep on sharing.
    Kubernetes Online Training

  16. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

    IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

    corporate training in chennai corporate training in chennai

    corporate training companies in india corporate training companies in india

    corporate training companies in chennai corporate training companies in chennai

    I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai Project Centers in Chennai

  17. The previous is rapidly turning into a favored system for web improvement, while the last is a virtualization technique that utilizes the Docker stage. handgun engraving near me

  18. In order to apply for a residence permit in Latvia based on financial investment in a bank you need to place with a bank at least EUR 280,000 in the form of subordinated capital and pay a state fee of EUR 25 000 to the government. The subordinated capital is funds that the bank is borrowing from a customer for a term of at least 5 years (Like a Corporate Bond – but where the corporation is a bank).

  19. It could be argued that the immigration process dates back to the very start of the human race. Since the begining of time humans have migrated from place to place in search of a better life and better security for themselves and their families. In the begining the challenges were purely logistical, how to safely travel to your new home, and how to live peacefully with the people and creatures already there. In the modern world there are also legal challenges. Immigration has became a subject of numerous disputes, but for many people it remains an opportunity to reach their goals and provide better security for themselves and their families.