You need to download and install these two requirements before we start.

Vagrant –

Virtual box -

If you’re done installing the above requirements, the next thing we’ll do is to create a Vagrantfile.


Alt Text

Vagrant.configure("2") do |config|

The "2" indicates the version of the Vagrantfile. This is the standard version configuration. = "centos/7"

This is the reason why we installed a virtualbox. Every Vagrant development environment requires a box. We set a centos7 dev environtment. "private_network", ip: ""

This section creates our private network. Using the dedicated IP will allow to access our host-only to the machine.

config.vm.synced_folder "files", "/home/vagrant/laravel"

This is the part where we specify which folders in Windows should be synchronized with the virtual machine.

config.vm.provider "virtualbox" do |vb|
vb.gui = true

You can comment out this part. But, in my case, I like to see what's happening when executing vagrant up.

config.vm.boot_timeout = 1800 # 30 minutes

By default, boot timeout is 5 minutes, but since I have a slow pc and internet connection, I adjusted it to 30 minutes booting timeout. :)

Ever wonder why we didn't need to install a docker in the first place? Because the remaining lines in our Vagrantfile are for the installation of docker. Yes! Once we execute vagrant up, the installation of the docker will be included.

Now that our Vagrantfile is ready, let's go ahead and execute vagrant up.

Alt Text

Alt Text

Once done, execute vagrant ssh

Alt Text

Remember the synced folder setup that we have in Vagrantfile? My laravel code is in the code folder. So I need to be in the code directory to access my laravel project.

Alt Text

Now that we are in the laravel project folder, we clone laradock by executing:

git clone
cd laradock

Once done, go to laradock folder.

cp .env-example .env

Rename env-example to .env.

docker-compose up-d mysql nginx

Execute command above after renaming env file. This will run the containers.

If you encounter an issue regarding mysql port is already in use, just stop the container and execute:

docker-compose up-d mysql

Alt TextAlt Text

Execute docker ps to see the containers.

Alt Text

Try to access your laravel project in the browser. You will see the same result as above screenshot.

Alt Text

The next thing we'll do is to migrate our database. To do that, execute below command first.

Alt Text

docker-compose exec workspace bash

Alt Text

Then execute laravel migration command.

php artisan migrate

If you want to access mysql in laradock, execute commands below.

Alt Text

docker-compose exec mysql mysql -u root -p mysql

This will ask for your root password. The default password is root.

show databases;
use default;

Default is the default database name. You can update this in the env file in laradock folder.

I know this is gonna be hard for us if we'll use the above steps in accessing our database. With that, we need to enable remote access of mysql in centos.

sudo -i

We need to be in a root environment to enable the remote access.

vi my.cnf

Go to /etc then execute vi my.cnf

cd /etc
vi my.cnf

Alt Text

Edit my.cnf file then save.

user = mysql
pid-file = /var/run/mysqld/
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address =
# skip-networking

Bind-address is your private network IP in your Vagrantfile.

I'm using HeidiSql for my mysql access.

Alt Text

Default password is root.

Alt Text

To exit:

Alt Text

docker-compose stop
vagrant halt

You can check my laravel-docker-vagrant-template repo for your reference at: