Was that a click bait headline or what! LOL, seriously though, if you have been thinking about learning about containers DON’T start with Kubernetes!
There is a lot of buzz around Kubernetes, containers, and Docker, and for good reason. However, Kubernetes is complex, and it’s really complex if you don’t know what a container is, or how basic container networking works!
Remember explaining what a VM was to someone 15 years ago? Remember how they were like WTF when you explained how one network card could have multiple VMs on different virtual networks?
So when someone asks “How can I learn about Kubernetes”, I tell them to take a step back and first learn Docker. I think it’s a great foundation before jumping into the Kubernetes (or K8s for short) world.
For my VMware friends out there, I compare Kubernetes to vCenter, and Docker to ESXi.
Docker is able to run containers, and do all sorts of really powerful stuff on a single host, just like ESXi. Things like running multiple workloads, creating networking between those workloads, etc.
Kubernetes simply brings more features to the party. Things like multi-node management, HA restart capabilities when things fail, more complex networking, and more.
So think back to how you get into virtualization. Most of us started with VMware Workstation, or a single ESX host. Then, once we were comfortable, we added vCenter management and started building more complex stuff.
Do the same thing with container technology! You will have more success than if you try and jump into the deep end day one.
My go-to tutorial for single host Docker
I have never written a “how to install docker on linux” post. There are already many great resources out there, and the one I always use is on Digital Ocean’s site. https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
This tutorial is SPOT ON for Ubuntu 18.04 and you can literally just copy paste the commands into a new machine and you will get a working docker box at the end.
So my recommendation on how to get started with Docker is that post. It doesn’t matter if you want to run Ubuntu in the cloud, on VMware, or on a physical machine… use that post to get Docker going once you have Ubuntu installed.
Let’s face it, most people don’t like the CLI. So there is a pretty powerful crutch out there for Docker called Portainer.
It only takes two commands to install, and the how to is here: https://www.portainer.io/installation/
This will let you see whats going on on your Docker machine, it also is handy for when you want to view logs, or jump into a BASH prompt inside a container.
I still recommend you use docker run, and docker-compose to start and stop your containers, just so you get used to it.
Speaking of docker-compose, you will want to install it too. Again … Digital Ocean = great content. https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-18-04
(the only thing I’ll tell you to do here is make sure you follow their instructions on getting the latest version … don’t just copy paste commands on this tutorial)
Docker-compose allows you to run multiple containers in a “Stack” and manage them as (lightweight) infrastructure as code.
For something like a simple WordPress server, you could run an apache container and a MySQL container, and then expose the ports for each of them. But there is a better way with docker-compose as it will setup some private networking between the containers in the stack and allow the two containers to talk privately to each other in a more secure way.
OK, so to sum this up here is what you need to do.
- Provision an Ubuntu machine (or your favorite Linux flavor)
- Install Docker via the Digital Ocean article
- Install Portainer
- Install docker-compose
Then you can start building single and multi-container apps and learn the basics of container management. Just like you learned VM management a while ago (stuff like power on/off, check logs, verify networking, etc)
You will be surprised how much of a workload a single machine can handle with containers! For some use cases, this might be as far as you need to go.
Once you are good with that, then I recommend moving on to learning the differences between Docker and Kubernetes. For me personally, this meant starting with k3s as it can get you up and running fast and you can start using commands like kubectl without too much fuss… but that’s a different post!