Docker

Published 2 years ago by SteveAzz

Hello, i just wanted to know if there is any toughs about talking about docker and setting it up with laravel, or is it better to stick with vagrant for laravel development since there is homestead

oleynikd

+1 I would love to see a Docker tutorial because it is a real pain-in-the-ass to setup a dev environment!!!

bobbybouwmann

I'm 99% sure that Jeffrey won't do a tutorial on this subject because it is so specific. There is not that much users that will use it here on Laracasts, since most users will be beginners or with some experience.

Anyway, does this help you out: http://www.dylanlindgren.com/docker-for-the-laravel-framework/

ohffs
ohffs
2 years ago (241,840 XP)

Personally I don't see what docker would add to laravel app development 99.9% of the time. Especially if you're developing on MacOS or Windows as you need to boot a VM anyway so may as well use vagrant/homestead. OpenVZ probably has more of a place imho.

Generally I only use docker for isolating single binary processes across various Linux distributions (for instance there's maybe a package ready-built for Ubuntu that you want to run on a CentOS server - so you can wrap it up in a container) and I can see the need if you require 100's of the same processes at scale - but in that case you probably have way more things to focus on than laravel itself.

theUnforgiven

Whats wrong with Homestead using Vagrant, easy enough to setup on both Windows and Mac and effective enough to run everything from. Just my opinion!

SteveAzz

@Istables Thing is you can take those container for production as well having less issues when you deploy into production. That is why i really want to get into it.

theUnforgiven

@Colossus you can do that already with Homestead. Then just copy/paste your env file.

SteveAzz

You are not understanding my point, you will have the same mysql version for example on both dev and production using the same container that allowd for automation and all of the CI goodness.

ohffs
ohffs
2 years ago (241,840 XP)

@Colossus and you can do that with vagrant dev - but without the hassles containers give you. If your production is, say, centos 6.5 with the vendor mysql, then just make a vagrant centos 6.5 box. In my experience of using containers, they can be useful but are full of traps that you need to watch out for (like dockerfiles that just install packages/libraries without specifying the version), monitoring them can be tricky without adding a load of other containers/stack stuff - whereas your current 'real' production environment probably has all that sorted in a well understood way.

mediascreen

Yes, a Docker dev environment + something like deployment of Docker containers to AWS Elesticbeanstalk would be super helpful.

christopher

Did you signed up at Docker and read the docu? The Tutorial is super helpful and with a bit of understanding you can setup your env by yourself with docker. particularly because docker comes with a super dooper UI (Kitematic).

Just read a bit and try it.

oleynikd

Docker is getting big! For sure now it's a trend. I guess it's not the place to discuss why, but for me it's like a development/deployment/production standardization tool. Many cloud providers (AWS, DigitalOcean, Azure, Google Cloud, etc.) now natively support Docker. You create your project configuration once and then use it anywhere and get absolutely the same environment, isn't it cool? It solves hundreds of problems!

@bobbybouwmann Yes, that's the ONLY one useful article I could find! But it's a bit old now and when I tried to implement everything I've read - I ran into a dozens of issues and now I have more questions then answers... :(

@JeffreyWay has a big talent to educate people, so I'm sure, my brain will be clear after watching his Docker series! By the way laracasts is one of the main reasons I chose Laravel for my current project. Thank you @JeffreyWay :)

mediascreen

@kayyyy It's not just about setting up a dev environment that works. It's about setting up something that is deployable to other environments in a way that works well with autoscaling.

Obviously it is possible to learn without Laracasts by reading documentation and trying, but that's true for everything else here on Laracasts as well ;-) And there seems to be an information gap between "how to set up a docker instance locally" and "here are the issues we at Spotify had setting up our production environment with docker".

ohffs
ohffs
2 years ago (241,840 XP)

Maybe I'm just getting old and jaded, but I can't help myself expecting the phrase 'web scale' to pop up ;-)

jgreen
jgreen
1 year ago (14,775 XP)

I'm not making the argument that Docker is a good subject for Laracasts, Dr. Way should be focusing on the 70-80% crowd, but Docker is exciting for us (at work) for several reasons.

  1. Our NetAdmins are not dev friendly and have locked us into Hyper-V for VMs, which renders Homestead/Vagrant/VirtualBox/PrettyMuchEverythingVMRelated useless. However, I can run a Linux HyperV VM that has Docker on it, which means I can have several containers in a single VM?

  2. There are tons of ready to roll "recipies" and Bitnami is getting on board, which is something we already use, so we don't have to completely revamp our server architectures.

  3. Dev = Test = Production in term of environment configs becomes a vastly reduced concern since the Docker images are the same. This is perhaps the one reason that should apply to "public" community not just those of us using Laravel in the Enterprise.

  4. dotEnv has some bleed over issues with running multiple virtual hosts on the same system, so attempted to host multiple sites in one VM can lead to weirdness. It doesn't really matter if you are using dotEnv, if you are stashing configs in the environment variable scope name collisions, mutability, superglobal exposure, and several other things are issues that need to be considered. Containers go along way towards eliminating these types of issues as each site is in its own space.

  5. Over provisioning your hardware with tons of VMs is super easy to do. I am not 100% versed in Docker but it seems you would be able to get more containers than VMs on the same hardware and not push your hardware provisioning so hard.

Don't dismiss these types of tools in favor of what ships with Laravel as the "out-of-the-box" tools are not always viable depending on the context of the project.

SteveAzz

So following this I have created my own package to dockerize your laravel application. It can be found right here : https://github.com/SteveAzz/laravel-docker

Sign In or create a forum account to participate in this discussion.