Josselin Dionisi - Freelance developer

Getting started with Docker

ionicons-v5-k Josselin Dionisi Dec 7, 2020
78 reads Level:

Ah Docker! I've been hearing about it for years, but like many people (I think) I hadn't yet taken the plunge.

I'd read several articles on this technology, and even looked at the official documentation to try and tweak a few things, but it was still too vague for me.

First of all, what is Docker? It's (almost) magic in the sense that you don't need to worry about your server configuration, your OS or your version of PHP, Node, React ... in short. You just code on your machine, and miraculously, if it works, it'll work in production too, no questions asked.

If you still want to know more, here's a link:

Orientation and setup | Docker Documentation

So that's great, but what's even greater is that Docker works with an image system. In other words, to install your environment in production, you'll need to use an image (a bit like ISO images, if you like). And this image can either be retrieved directly from Docker Hub (if you don't need anything special compared to a standard configuration), or you can configure it yourself.

And the advantage of this is that, once you've made the image, you can reuse it for each and every one of your projects...? Not to mention that ready-made images already exist for Wordpress, Prestashop, etc.

You're feeling the magic now, aren't you?

My experience

Obviously, when I understood all this and saw a few lines of commands that I quickly wrote down on " Bear ", I wanted to try it out.

I almost always develop my backend in Symfony, so this was my first objective: to create my own Docker image that launches a Symfony environment.

So I started with an image of PHP version 7.4, added to an image of Nginx and MySQL to have a complete LAMP environment under Docker.

I did a bit of research into how best to write this without forgetting PHP's essential extensions to all the dependencies, and in half a day my Dockerfile was up and running with docker-compose, which launches the containers.

All I had to do was type in the Symfony command to create a new project

All I had to do was create my new project with Composer accessible and a linked Mysql database?

If you'd like to use this configuration, I've made it available on Github: GitHub - boreales/sf4-docker: Symfony LTS + Nginx + Mysql