ekandreas

Jeffrey should really recap Docker as a dev env cause it's not furure safe to continue with Vagrant based environments.

bugsysha

I've switched to docker but I keep homestead as backup just in case I do not know how to do something with docker, but that didn't happen yet.

jonaspas

A docker series on laracasts would be great!

omurphy

+1 - I would definitely like to see this as well.

FYI, Chris Fidao just released a good beginners tutorial called Shipping Docker here: https://shippingdocker.com/

Still, it couldn't hurt to have Jeff add his master touch to the subject.

primordial

I can understand @jefferyway not producing a series on docker, @taylorotwell endorses homestead for starters. I have never used Homestead but Docker containers are also very small and I don't think the homestead platform has a solution to compete with the convenience of Docker Swarm(?)

pmall
pmall
7 months ago (574,745 XP)

I started using docker for managing my environment and it is fantastic. No more worries about provisioning redis, laravel echo server, workers queue, blahblah blah, just make a suitable image for each process, use docker-compose to orchestrate them and your done. I may write on this topic someday.

If you need advices you can ask me.

primordial

If anybody wants an image to start I created https://hub.docker.com/r/primordial/alpine-nginx-php7/ for my stuff and same as @pmail; happy to help.

bluebeard

+1

Ruffles
Ruffles
6 months ago (264,860 XP)

I am using Laradock: Like Laravel Homestead but for Docker instead of Vagrant. for personal projects and it works great on Windows!

fideloper

I'm creating Shipping Docker which will go in-depth on teaching Docker for development and production.

There's a free mini-course on getting up and running for development (along with explanation of what's going on)!

Definitely sign on up there to get some extra videos and notified when it's out! (And of course coupons, blah blah blah)

michaelmano

Hey so anyone still wanting to use docker with Laravel, Here is one running PHP7.0, MySQL 5.7 and Nginx I have set up and use all the time.

https://github.com/michaelmano/Dockers ( you will not require these files. This is just the repo You will only require Docker installed )

Getting Started

You do not require any files except Docker installed.

If you are starting a new project from scratch this container will create a Laravel project in the path you provide it and update the .env to the dockers database details. If you have an existing project and you provide it the path it will not install Laravel but instead use your project.

If you destory your docker when you are finished the files will be left on your computer so you will not lose anything (except the database however if you are using migrations and seeders you should be fine - if you require the database I suggest you do a mysql dump before hand with the dockers exec command).

Commands

Creating a Container The command below will spin up a new docker container named my-project running on port 80, You can change this if you have multiple projects by altering the -p 80:80 to -p 8888:80 (8888 to any port you prefer).

docker run --name my-project -itd -v /path/of/project:/var/www -p 80:80 -P michaelmano/laravel

Running Commands on the Container

docker exec -it my-project /bin/bash -c "php artisan migrate"

or open a console in the container

docker exec -it my-project /bin/bash

Destroying a Container This will leave the project folder it was using so all files will be safe.

docker rm my-project -f

Checking the Container Status

docker ps -a

This will show the containers you have running and on which port however you can use dockers Kitematic which is a visual interface for this also.

MySQL Details

  • dbname: docker
  • user: docker
  • pass: docker

TODO

  • Automatic install of laravel - (Completed)
michaelmano

Just an update to the above post. I have now added sqlite to the docker so testing is possible in memory with sqlite.

just update your phpunit.xml to the following around line 27. I will also do this automatically on install of a new project.

        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>

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