Admin Docker Laravel Programming Tutorials Web Dev

One minute Laravel and Docker Tutorial

In this short lesson we’re gonna focus on two topics we tackled some time ago in this mini series of tutorials: Laravel and Docker.

In the getting started section of the Laravel project’s documentation we can see that a vagrant box named Homestead is strongly adviced to begin with a quick and smooth developing experience.

Benedict.Cloud tutorial

Homestead is pre-packed with all the stuff necessary to begin the development of a Laravel application, but when it comes to deploying any application, Docker has many strong points that other virtual environments have not. In many cases it is a must: see this article of mine for further details.

In this tutorial then, we’re going to put together two concepts we saw in our previous lessons, please refer to this other blog post of this series along with the one on Docker linked above: the episode about Laravel.

It may also be useful to look at our Ruby on Rails tutorial to get a general picture, that one is also based on Docker.

The first thing to do is to create our Laravel stack, it will be based on the bitnami Laravel docker containers, go to your shell and type the following commands:

$ mkdir laravel_tutorial && cd laravel_tutorial
$ curl -LO
$ docker-compose up

Your Laravel default application should be up and running after a few time for downloading all the images from the repos. All you have to do now is to point your browser at this location: and you should see the default Laravel welcome page.

The next thing you should do is to open another terminal within your shell and issue the following command, you will enter your container’s shell:

$ docker exec -it laravel_tutorial_myapp_1 /bin/bash

Now all you have to do is to follow the instructions from this previous tutorial of mine, the only difference is that all the shell commands will be issued inside the container’s shell, and the final command to start the artisan server will not be necessary, in that artisan will be already running: so here you can continue the lesson.

And that’s all for now, in this quick lesson we looked at a very simple Laravel application running on Docker. We saw two development environments, Homestead and Docker, and we quickly discussed them.

This tutorial is based on Fedora 29, you might encounter some little difficulties running the same application on other operating systems such as Ubuntu, but with a little bit of patience you can surely overcome them.

A useful Laravel guide suggested by Marisela Ordaz from Toptal, an hiring platform, can be found at this link. Enjoy it, you might find the job of your dreams.

Should you have any more question, I welcome you to contact me in person and I’ll be answering as soon as possible.

If you need a reference for the inherent code, the repo is the same of the preceding Laravel tutorial: go to my GitHub. In addition to that repo you will also find a ‘docker-compose.yml‘ file inside your app’s root directory.

Did you like this post? Please, share it on your preferred social networks, thank you! Do you like the way I write code? Hire me! My email is on the homepage, let's make a chat to see if we can work together.