Skip to content

Instantly share code, notes, and snippets.

@tororutsu
Created January 4, 2022 00:32
Show Gist options
  • Save tororutsu/001416585e4717837ecb0b88a00353ef to your computer and use it in GitHub Desktop.
Save tororutsu/001416585e4717837ecb0b88a00353ef to your computer and use it in GitHub Desktop.

Containers & Me

Containers are amazing, no not Docker, but what Docker made famous. The idea of putting all of your code in a standalone image and having that image be portable changed the game. This isn't some grand journey into containers, but my thoughts on them and how they have helped me in my journey in tech! Hmm maybe "helped" isnt the best term to use, because I spent more time struggling with containers then I have using them lol. Why struggle you ask, well because containers arn't going anywhere, and the faster I learn to use them, the faster I can catch up to the rest of the tech world; not that I am trying to!

The Appeal

Containers appeal to me in a way that fire appeals to a kid. You see the fire, you touch the fire, you get burned, complain for a little, then learn how to use fire because you think its cool. When I first started using containers I had no idea what I was doing, to an extent I still don't. A friend told me that I can use containers to put a bunch of websites or applications on one server and have them be completely isolated from one another. Not only would they be isolated but they would hardly use any system resources, if you read my last blog you would know that I am a sucker for system resources lol. When I heard that I was sold, I was thinking of buying cheap servers and hosting many different things and saving boatloads of money. Well yeah that didn't work according to plan!

The Failure

So apparently its not so easy to just have things work, their is a lot of learning that comes into place, huh, who would've thought. As the heading stated, I failed. A lot. The first problem I ran into was actually networking. Think about it like this, I have a banking app that has a front-end and a database. On my server I would have the database running and my front-end would be connected to it. I would then use NGINX to route that data to port 80 and my app would be visible to the world. That was a very bad technical explanation, but I plan on blogging about it another time, so we should be fine for now. Anyways, now say I wanted to run the same program as a container, the process would actually be almost the same. I would setup the database, connect to the front-end and then I would server it through NGINX. However even if the logic is the same, the method is not. I was told containers follow along with the UNIX philosophy; Do One Thing, and Do it Well. Thinking in that regard, the container is not suppose to house the whole app, but only one piece. So the above example would be one container for the front-end, one container for the database, and one container for NGINX. TRUE isolation!! But wait, how are these containers talking to each other!! Exactly my problem as well, because the containers were isolated, they couldnt be connected. Thats where networking comes in to play.

Learning the Hard Way

Docker, our container controller, allows us to create virtual networks. Therefore I can create a network, bank-app, and have all the containers connect to it. Being on the same network allows my front-end and database to talk to each other. Boom, I figured it out, now its time to rule the world!! Not so fast, my containers might be connected to each other but are they connected to the internet. Well actually no they are not! Thats were I learned that NGINX is a lot more powerful annd complicated then I thought!! Although I had NGINX running and connected to the containers, since NGINX is also a container, what is connected to that container to allow it to connect to the internet, nothing!!! So then I had to find a way to connect NGINX to the internet, thats when I learned about port mapping. Well it didnt stop there, I had to learn about volumes, ingress, more networking, then I found security flaws, which I had to fix. Overall it became one huge mess, and I got scared and ran away!

Whats Next

Here I am a couple years later, back at containers again! Even as I write this post, I am still fighting with containers. The only difference is, I can't run this time. So although you didn't learn anything in this post, and probably never will, I encourage you to follow me on this journey to learning containers. I will be blogging about the things I learn, and you will get to see first hand the path I take to container mastery. It will definitly not be pretty, and it will probably be boring, but nevertheless we will sail forward and conquer!! Till next time!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment