What Is Docker?

Before Docker, there was Vagrant. Vagrant was pretty easy to understand because it mirrored a simple server where you would install packages and programs.

Docker is a lot different than your average server. It’s confusing to understand, at first, but there are multiple reasons to use a program like Docker, like its portability and containability (not a word).

Containability (Visibility)

As a web developer, you’ll have to use a lot of different packages and programs, like MySQL, Nginx, and PHP. It’s possible to install everything on your host machine, but it can get messy pretty quickly. With Docker, you can install a lot of different programs and packages without worrying about messing up your machine’s environment. When I say “host machine”, I am referring to your computer (Mac or PC).

Portability

Using Docker for your local development environment also has another big benefit. If you move to another machine, or if you develop on multiple machines (computers), getting set up on the second machine will be a lot easier and faster than starting from scratch.

How does Docker work?

Docker doesn’t work like a normal server. If you’re used to setting up/provisioning normal servers, Docker won’t be very intuitive. In Docker, you don’t install everything (PHP, Ngint, MySQL) on one server. You install each program in its own “container.” I suppose there are good reasons to do it that way. Each container/service can communicate with each other through a network. It’s a completely different way of thinking about servers. Thankfully, Docker has a lot of pre-built images (instructions for a container), and I would recommend using those whenever possible. Without those, setting up a local development environment with Docker could take a lot longer than using Vagrant. Another thing to know about Docker is that it’s pretty slow when using Laravel. It’s not just your machine. Despite all of those cons, I would recommend learning it because it will look good on your resume, and it’s probably the way of the future.

When using Docker, I’d recommend using configuration file (docker-compose.yaml), off the bat instead of using Docker commands. For each Docker command, there is an equivalent configuration. Since you won’t be using Docker that much, it will be a lot quicker to just learn the configuration. You’ll need to use a terminal or command prompt to run Docker commands.

The two commands I use 99.9% of the time are “docker-compose up – d” and “docker-compose down”. That’s it. I use “docker-compose up -d –build” when I add something new to the docker image.

The docker-compose.yaml file will contain all of the configuration for your project.

Once you have your configuration file set up, you’re good to go.

Docker took me a long time to figure out. If you want someone to walk you through it, you can sign up for a free 30-minute coding session. You can also sign up for Pair Code Pro and get two tutoring sessions per month.