Dockerizing

stella ireri
NAL Coders
Published in
5 min readJul 6, 2018

I think am one of those people who love to procrastinate things so much whenever i have the “this does not work for me now… i’ll give it a try later”. Well that “later” is overrated. Another thing, what do you really do when you feel so wasted after trying 3–6 ways of getting it done but still you hitting a snag over and over? I bet most of my colleagues will say, go to sleep, watch a movie, go clubbing, take a beer or two for the road etc. I tried something different to get destructed, i did my laundry!! Yeees, you heard me right, i went washing clothes in the middle of the night just to get my head clean and destructed. and mind you, it worked real magic. How i opted to do laundry instead of following my favourite series, is still strange but that’s a story for another day.

Docker……

The first time i heard about this thing was in 2016, after my friends finished a summer internship program and had this nice looking t-shirts with Docker writings on them and they would gang up and wear them on the same day and whenever you’re hanging out with the them on such a day, you feel like the odd one out because you really are. That aside, i still didn’t get it then, but i still would mention it severally to other people just to look techy and informed around a bunch of guys. Two years down the line, i haven’t had the guts to dive into its magic coz i didn’t feel like it was that necessary. It was not until i just had to do it for good! — like my life depends on it!

So after finishing my laundry, and took supper, i still didn’t know which approach would work for me this time round, so again i was on the web from 11 pm trying to see if had exhausted my resources of knowledge outsourcing. 20 minutes into my search, i came across this article that took me by a blow!!! It just did the magic. The author of https://www.katacoda.com must have had me in their mind. This interactive platform for software engineers just saved my ass. I did the first scenario of docker and containers lesson even before i could sign up in the platform. It seemed easy peezy maybe because i had come across the same commands during the day, or i was really psyched up for the course one more time.

To hell with my note book, i had to take a different approach this time round of noting the important facts during my lesson. I had my note pad with me. and this stuff was really flowing like a river, just what i needed! My first dummy site was up and running!.The commands were doing an awesome stuff too… all passing and making me feel like i was made to do this for the rest of my life.

Setting Dockerfile
build and run
launched!

At 2 am in the morning i was still up and digging more to what i could find. before i slept i had to save my notes and share them with you too. I bet i slept like a baby after a successful search.

my notes looks a bit sketchy but i still did an awesome job with them

Docker -a platform for devs, sysadmins to build, ship and run distributed apps

container- a process running an application and its dependencies on the host OS

docker inspect — gives more information about a running container e.g. ip addr

docker logs- displays messages the container has written to std out/ std error

docker port <container name> <portNo> — displays the port a random running container has been allocated.

Docker run –name <cont.name> -v <host-dir>:<container-dir> — binds data beteween directories for upgrades and any changes

host directory can use $PWD as a placeholder

docker build -t(friendly name for buid):version number -used to build images locally

docker run -d -p 80:80 <firendly name>:tag version runs the app in the specified port

curl docker- launches the image

all docker images start from base image.

base image — same images from the docker registry that are used to start containers.

Creating dockerfile as the base image has 2 main commands

1. RUN <command>- this allows you to to execute any command as you would with a cmd

2. COPY <src><destination>- allows you to copy files from the directory containing dockerfile to container’s image

- if you are copying a file then you need to specify the the filename to the destination.

3. EXPOSE <port> — defines the port to be accessed by the image

4. CMD –default commands to run that launches the application in the container. If the command requires arguments passed to it, then an array is used.

Docker build -turns the dockerfile into an image

- build command takes the directory containing the dockerfile, executes the steps and stores the image in your local docker engine.

Docker build <friendly-name:tag-version .>

Docker run -d(detached mode/background process) -p 80:80 <friendlyname:tag>

curl -i <url>/docker — returns the html file.

My night adventure ends there, i still have alot on my plate to ganner and prepare for a demo to the awesome crew

Photo by Konstantin Planinski on Unsplash

--

--