Why Containers?

What is so special about Containers and why should I care? If you are like me you heard this term of containers and you sort of got it but at the same time you didn’t.

Shipyard with containers

So perhaps think of it this way, the shipping container analogy, where say you want to move all the stuff from your home in Spain to Canada. You would go get a shipping container and you would stuff your stuff in there and send it off, maybe you pack it full or maybe it is half empty – you choose. Why are shipping containers effective and efficient, well for one they are big enough to get a lot done and they are a universal size so that transporting them is straightforward. You don’t have to send along dimensions, weight, worry about if it will fit on a truck or a cargo ship, all those logistics are handled.

In the context of a Docker Container there are similarities in that you put all of your code into a container and you include all the underlying software you need to run your application in the container, but you don’t include the stuff you don’t need. So let’s say you want a lightweight OS like Alpine and a web server, (nginx), and you want PHP and you want CURL and Nano and your source code and you want to be able to ship it to someone else so they can run it. Well you specify the OS and all the programs you want and bundle in the code and you create a Docker Container. Then you can post your container to DockerHub and then share it with your colleague. When your colleague gets it all they need is the container, they don’t need to install Alpine or Nginx or PHP or download your code, all they need is that container. You also know that it will run once your colleague gets it because it runs the same everywhere and you don’t have to worry if there is some weird configuration issue that is causing issues because you build it once and share it everywhere.