The Docker Tutorial
Docker makes development and deployment much easier, since it removes the need for installing and configuring software on your server or local machine. But there are a lot of options out there, and getting started can sometimes be a bit overwhelming.
Follow along in this series, as we learn how to use Docker from a beginner’s point of view. By the conclusion, you’ll have a complete and production-ready environment for your own projects.
What is Docker
Let’s start at the very beginning. We’ll discover what Docker is and why containers are so popular. Then you’ll learn how to pull images from the Docker Hub, and what happens when you run a container.
Create a Simple Dockerfile
We’ve seen how to use ready-made images, but what about creating one of our own? After writing just a few lines, we can spin up a custom image complete with an operating system of our choice.
Setting Up Nginx
Now we can begin building out what we’ll use to run any Laravel application. First thing’s first: in order to process requests from the browser, we need a web server. Nginx is a perfect fit for the job.
Docker Compose and MySQL
It’s time to add a database for our application, but that means we’ll need to separately balance two different containers. Docker ships with built-in software that makes this easy, and it all starts with a single file.
A PHP Container
We’re getting closer to running our application, and the last piece we need is a PHP container. This one is a bit tricky, since there can be some issues with file permissions. But don’t worry, there’s a workaround that we can use to glide right through.
Use Composer With Docker
During development and deployment, you’re bound to use Composer to install, update, or configure packages in your application. Let’s spin that off into its own container so we can make Docker do the work for us, without having to install any additional software.
Running Artisan and NPM
In this episode, just like we saw with Composer, we’ll offload running npm and artisan scripts to a separate container. This way, we can run multiple commands at once, all without blocking the main container serving our app.
Packaging for Distribution
Right now, we have a great environment for local Laravel development. We could deploy this setup just like it is, but with a few small tweaks and a couple additions, we can make our containers faster and more secure for production environments.
There are no reviews yet.