What is Docker? What are containers?
Dave’s a sys. admin!
Dave spends most of his time looking at:
- checking out resource usages
- debugging things
- and maintaining build configurations.
Amy’s a web developer.
Amy spends most of her time looking at:
- choosing the best stack to go with for her web application
- and following build configurations.
Do you see the problem?
Dave needs to constantly get familiar with the changes in the stack Amy uses in order to maintain build configurations for them!
Time he should’ve been able to spend on ensuring security in the server and optimizing usage etc. 😞
1. Containers solve the issue of “Separation of Concerns”
Using containers, Amy will divide her application up into small microservices, and make each responsible for a part of this larger function.
Now Dave can focus on working with the kernel files, optimizing security etc, and Amy can build her application, maintaining her own build configurations, with the occasional supervision from Dave’ side.
What’ll that look like?
In the diagram above, you can see an online shopping service being divided into 4 moving parts (the different containers).
Each of the tasks above are large enough to be a service of their own.
Now you might say:
I’ve been making online shops for years without containers
This approach gets us 3 things:
- High Scalability — With this approach you can scale any of the 4 containers to any size without causing issues for your other containers 💯
- Separate Builds — When rolling out updates for the “Cart Server”, you no longer need to rebuild the whole product. 🔥
- Separate Teams — You can now assign each one of the 4 parts of this web application to a separate team. They do not need to constantly work together, and can each focus on making that specific function great.👌
2. Docker solves the issue of “Running the app in dev & test environments”
Sarah, the designer in the team, needs to keep the web application running on her Macbook Pro, so that she can keep analyzing the UX, and designing more and more awesome pages.
- Dev, Test & Production Environments—Docker containers are like enhanced Virtual Machines. Once your application works in one, it will work on any computer/server whether it’s Linux, Windows or Mac. 🙏
3. Almost no downtime!
You can always write scripts to load-balance your docker containers.
The idea is that, for a specific function (e.g. our online shop’s front-end), you would run two identical containers, so that if anything goes wrong, or there’s an update, you simply:
- Flag 1 container to stop taking more connections in
- Take that container down
- Update it to the newest version, or just restart it for being faulty
- Bring it back up (voila! 🎉)
So What exactly is Docker now?
When my colleague showed me Docker for the first time, I was really confused by their explanation of what it does.
Turns out that’s exactly what Docker does!
Docker does the same as virtual machines do, but in a much better way.
It uses the “Docker Engine” to install only 1 instance of the OS, but run as many as you need, without actually installing more instances.
The engine will run on top of the Host OS, sharing the kernel files within your containers, and tricking them to believe that they are each in their own brand-new environment, at isolation.
As a result, you get your blazing-fast lightweight containers.
Shut up and tell me where to get started 😍!
I will be posting more introductory tutorials in the following weeks to get you started; in the meantime you can look into these:
Where do I run Docker?
Many cloud platforms currently have added support for Docker. One product that I recently saw at a conference really blew me away though!
Cycle has been developed as a cloud platform, with a 100% focus on the containerization approach.
Here’s how to run a Docker image on the cloud
1. Signup on cycle.io
2. Go to your dashboard -> Click on “Images” from the sidebar, and then “Import Docker Image”
3. We’re going to import the official NGINX image.
This will tell cycle to lookup the nginx image on Docker Hub:
4. After clicking on “Import Image”, cycle will pull the specified image, verify its authenticity, save it and clean it.
At which point you can click on “Go to Image” to see it
5. Click on “Environments” from the sidebar, then “Create a New Environment”
6. Name your new environment and press “Create Environment”
6. Open the environment we just created, then click on “Create Container”
7. Enter a name for your container, and make sure that the nginx image is chosen as the image for our new container.
8. Choose a datacenter to host the container on, and press “Create Container”
9. At this point we’re all set, and just need to start our container
10. After the container is successfully started, you will get an IP Address, which will point to port 80 of your environment.
11. Now if you go to that IP Address, you will see a blank NGINX project.
Stay tuned for more Docker tutorials! 😉