Container Concepts
What are containers?
Containers are isolated environments that can run on any host. They are a great way to package your application and all of its dependencies into a single unit that can be easily deployed to any environment.
Why containerize at all?
Going through the efforts of containerizing your application gives you one extremely powerful capability:
👉 You can run your application anywhere.
Once you're at this level, you unlock a ton of new possibilities:
- Your application runs the same across Mac, Windows, and Linux - no more "it works on my machine". Run 100% of your application on any operating system. All they need is Docker installed.
- Ship with more confidence - all infrastructure configurations are centrally managed in Git, so you can change, test and rollback with ease
- No more vendor lock-in - if a host raises their prices on you, you can migrate with very little effort
- Scaling is a breeze - once you get your application in one container, it's so easy to scale up to any number of containers
- Improved security - containerized apps are more secure than traditional apps because they are isolated from the host
- Better uptime - if something fails during deployment, you can roll back your application to a previous version
The crazier part is you don't need a Platform as an expensive Service (PaaS) to get all these benefits. Everything can be done with 100% free and open source tools.
Docker vs. Containers
When you're first learning about containers, you'll likely hear the terms "Docker" and "containers" used interchangeably. While they are related, they are not the same thing. Docker is an open source utility for building, shipping, and running applications in containers. It's one of the most popular tools for containerization.
Although you may see us reference things as "Docker containers", we're actually referring to the broader concept of containers because containers follow a standard known as the OCI (Open Container Initiative). This means Docker containers can run on any container orchestrator that supports the OCI standard (like Kubernetes, Docker Swarm, Docker Compose, HashiCorp Nomad, etc.).
So although we're going to show you best practices with Docker, this means you'll maintain your freedom and flexibility to choose how you want to run your containers.
How to get started with Docker
At first, Docker may seem a little intimidating, but don't let that stop you. Docker is one of the most powerful skill-sets that we've learned in our career.
Although teaching you how to use Docker is beyond the scope of serversideup/php, we've actually created another open source project called Spin that dramatically reduces the learning curve for getting started and self-hosting with Docker on any VPS provider.
Spin is free and open source, and it's a great way to get started with Docker if you're looking for a free method to deploy to any VPS provider.
Learn more about Spin