Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Facing Past Fears: A Journey to Conquer Docker

How do you learn something that has been tripping you ever since you started? You face it head-on. But how do you conquer it? Well…Photo by Rubaitul Azad on UnsplashDocker. A technology that allows people to run their apps inside of miniature virtual machines (called containers) that can ship to any hardware at any time. A piece of modern development so crucial that it singlehandedly fixed the issue of cross-platform web development.Gone are the days of being forced to use Linux as your main build environment simply because your company servers use Ubuntu, and that building your app in Windows will result in incompatible drivers. Those are the days of old. Even today, cross-platform development technologies are still continuing to evolve, with Solomon Hykes (the guy who authored Docker) stating that if the WebAssembly Interface had existed in 2008, there would be no need to create Docker.Solomon Hykes / @[email protected] on Twitter: "If WASM+WASI existed in 2008, we wouldn't have Needed to created Docker. That's how important it is. Webassembly on the server is the future of computing. A standardized system interface was the missing link. Let's hope WASI is up to the task! https://t.co/wnXQg4kwa4 / Twitter"If WASM+WASI existed in 2008, we wouldn't have needed to created Docker. That's how important it is. Webassembly on the server is the future of computing. A standardized system interface was the missing link. Let's hope WASI is up to the task! https://t.co/wnXQg4kwa4Yet even today, Docker still stands as the industry standard. So, as a fledgling backend developer, it was paramount that I had to learn Docker sooner or later, one way or another. But my experience… was not so great on the first try.Day 0: Falling Face-First, ForwardPhoto by Derek Thomson on UnsplashBaby steps — the way everybody learns something new is by taking small steps that gradually get bigger and bigger the more you learn. But, without guidance, such fragile legs would never even be able to stand on their own, and let alone walk.It all started a few years back, when I came across a YouTube tutorial by Jake Wright titled: “Learn Docker in 12 minutes.” It was a wonderful crash course on interacting with Dockerfiles and learning the basics of making your own container.https://medium.com/media/4fecd9b7975a9b136cd32acd79307c16/hrefExcept there was one small problem: I did not use PHP; I used Rust. I looked everywhere on YouTube for a hint on how one could deploy a Rust application inside of a container and found a video where Chris Biscardi deploys a Rust backend written in Axum inside of a container via Fly.io. I followed it through as much as I could, line-by-line, from head to toe and all the way downstream.https://medium.com/media/70ae551a1b55d6d65697e013b231fbb2/hrefBut in the end, none of it mattered. Following all that led me to create a faulty container that barely even worked, let alone serve. I did not deploy in Fly since I really only intended it to be a learning experience done locally in case I’d ever want to deploy later, but still. Even worse was that I had no idea how to configure the Docker daemon.I spent hours figuring out how to keep the daemon running and serving as needed. Note that this was way before ChatGPT became public, so I had no guidance and was completely disheartened. The entire ordeal made me fall face-first forward and become afraid of using Docker — at least until the 27th of May, 2023.Day 1: Coming Back With A FriendPhoto by Aaron Burden on UnsplashIt was the last full week of May 2023. My work had loosened, and I had all the time in the world to catch up to my goals, including preparing for Computer Science and getting back into programming. I hadn’t written a single line of code since February, and I felt demented, but even I felt that it needed to change as soon as possible, so I got to work.One of my goals during the final full week was to learn Docker — the right way this time. I had ChatGPT to use in case I had any questions I couldn’t answer online and a new development environment using WSL2. I managed to install Docker properly, but the daemon was acting up, with exactly the same issue I had before. But not today, I said.I promptly asked ChatGPT how to configure the Docker daemon to run and stay at startup inside of a WSL2 Ubuntu instance, and just like that, it was as if all my burdens had been lifted and my shoulders were free to move!The Docker daemon was working!It was running! I can now use Docker commands as I’d never been able to before, with a little bit of help from our AI companion and a reason to believe. My goal to learn containerization was closer than ever, and my fear of it slowly dissipated into thin air. I just needed to hold my hand out; the trophy was mine for the taking!I already had a plan for what I wanted to containerize — a simple “Hello, Docker!” API that had only one endpoint exclaiming that greeting as a sign of accomplishment to whoever has gotten this far. There were also no worries about port forwarding since WSL2 did all of that for me.Henceforth, with a little bit of Actix Web combined with a simple Dockerfile (also helpfully taught to me by GPT), we got ourselves a working Rust backend service hosted inside of its own isolated container — for the first time in my life. Next, time to connect this service to a proper working database.Day 2: Veni, Vidi, ViciPhoto by Todd Cravens on UnsplashYesterday, success revved me to start with high hopes as I began writing a barebones CRUD API meant to be connected to a Postgres container. This was when I learned about Docker networks, secrets, and compose (even though none of the first two were used in the final iteration).The process went significantly smoother than any of the other times I’d worked with Docker, and most of my problems came from SQLx macros that required an open database before building. This caused me a massive headache as the container wouldn’t properly build (and compose) without fixing the issue first. Even worse was that the documentation for SQLx focused more on its macros and, therefore, lacked cases where they weren’t used.Thankfully, ChatGPT knew how to use SQLx’s query functions, and all problems were fixed relatively easily. The containers were built and composed, and the entire service was working just as intended, with the app and the database communicating. Here is a repo featuring the culmination of everything I’ve learned and everything that has happened so far in this article.GitHub - Idontknow13/rustwithdataFacing Past FearsPhoto by Cristina Gottardi on UnsplashWhen you start losing too much, sadness starts to kick in. Sometimes, kicking it back out takes a long time. Maybe all you needed was a little rest, some self-reflection, or light coffee. But once you’re feeling better, come back with a clear mind and look at the problem without any haziness in your vision. Maybe you lost because you didn’t have any patience, missed something crucial that you only figured out now, or missed a companion to help you.Either way, face them. If you took up a challenge before, that means you were confident you could beat it, and your loss just meant you were missing something. Now you have what you lack, so return. Maybe this time, you can win.Facing Past Fears: A Journey to Conquer Docker was originally published in Better Programming on Medium, where people are continuing the conversation by highlighting and responding to this story.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Facing Past Fears: A Journey to Conquer Docker

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×