L&D series: Embark on a Docker voyage with Whiny the whale

Ferawati Hartanti Pratiwi
4 min readOct 17, 2020

--

https://pbs.twimg.com/media/CLxCZpGUcAAmEsY.png

Learning and Development chapter 9.

“Focus on what you can control” — somebody said this to me. So, let me take a vacation to explore something with a fictional character named Whiny in the midst of this uncontrolled pandemic (this is one wish that I want to fulfill).

A long long long time ago, I tried an interview in one of the big company. One of the requirements of the position is Docker. What is Docker? And why it is so damn popular? In fact, many companies have included Docker on their list of job requirements (things that I only found out at a later date).

Docker

I would say that Docker is a open source tool that simplifies our workflow from building applications to deploying them in any environment. Docker provided a container to allow us to create an application (with the libraries and dependencies) as one package. For example, I’m using MacBook (with masOS Catalina) but my team provided Linux as a server, this difference will be resolved using docker.

So, how do you build Docker? (sorry but I don’t get the author’s explanation etc. Just get to the practice!). And who is this Whiny? (he’s cute actually)

Okay got it, Captain (roger with thanks on behalf of Whiny). For information, since I’m using macOS, I will only explain for macOS needs only. Let’s have a sail !!!

Installation

Docker run result

Create Project

Just create any simple project to start. I have main.go file. What would I do with this file? Keep that mind to create the content of our Dockerfile.

Project structure

Create Image

What is image?

A Docker image is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform. It provides a convenient way to package up applications and preconfigured server environments, which you can use for your own private use or share publicly with other Docker users.

Docker images are also the starting point for anyone using Docker for the first time. — https://jfrog.com/knowledge-base/a-beginners-guide-to-understanding-and-building-docker-images/

Let’s build our first image.

$ docker build -t docker-go-test .

Explanation :

--tag , -t Name and optionally a tag in the ‘name:tag’ format — https://docs.docker.com/engine/reference/commandline/build/

Give any name you want for your first c̵̵̵h̵̵̵i̵̵̵l̵̵̵d̵ image.

https://pbs.twimg.com/media/DK0fg8CU8AAfxEf.jpg

Run Image

$ docker run docker-go-test

You will see Whiny say a greetings inside a container.

Image result

So, Whiny is the courier in charge of delivering what we’ve created to any environment. He is the whale who will cry if he can’t convey his mandate. So, as a proof that he has carried out his mandate, he conveys greetings after run the mandate successfully. Good job, Whiny ! (Don’t cry anymore :D)

https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTM2F6y4MtZijWXVPieD9AndXzh8hVqU3QmSQ&usqp=CAU

Tips and trick

https://jfrog--c.documentforce.com/servlet/servlet.ImageServer?id=0151r000006uDeS&oid=00D20000000M3v0&lastMod=1584629589000
  • List all images

$ docker image ls

  • List all containers

$ docker ps-a

  • Start a container

$ docker start [CONTAINER ID]

  • Stop a container

$ docker stop [CONTAINER ID]

  • Delete all containers

$ docker rm -vf $(docker ps -a -q)

  • Delete all images

$ docker rmi -f $(docker images -a -q)

  • See container’s logs

$ docker logs [CONTAINER ID]

  • Docker run

https://docs.docker.com/engine/reference/commandline/run/

  • Cheat sheet

https://kapeli.com/cheat_sheets/Dockerfile.docset/Contents/Resources/Documents/index

--

--

Ferawati Hartanti Pratiwi
Ferawati Hartanti Pratiwi

Written by Ferawati Hartanti Pratiwi

Continuously striving to elevate QA standards with a quality-focused mindset

No responses yet