Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the requirements, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can be assured that the application will run on any other machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.
Docker (and container system in general) are commonly confused with virtual machines. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application. You can learn more about containers here.
Because all the work is done to prepare the project within the container on it’s extremely useful in development as well as production to spinning up disposable services a single line such as
will setup a running postgres server ready to accept connections, this can be done with most tools and apps like mysql, wordpress, and drupal.
Containers are just scratching the surface of docker, it also supports docker volumes which isolates data and docker network which allow containers to run on entirely isolated and private networks, with set ports between them adding an extra layer of protection.
Docker Compose is by far my most loved feature of docker, it allows me to create an entire development or live environment with all the moving parts, all private networks and volumes (mounting local files for testing) by using a single config file: docker-compose.yml. This can mirror or even be used in production, removing the “it works on my environment” argument from the equation.
Here’s an example docker-compose.yml to spin up a simple wordpress