From Zero to Microservice [2]

How to Dockerize Your App & Deploy using Kubernetes?

Yamac Eren Ay
7 min readJan 8

--

Previous articles:

Fig 1: How deployment figuratively looks like, Source: https://entwickler.de/programmierung/deployment-automatisch-praktisch-gut-001

Step 0: Get a Project

I created a GitHub repository person_grpc [1]: a Go package, which serves as a personal database, dealing with get / set person commands. The communication between server and client is achieved using gRPC (built on top of TCP).

Step 1: Go Project => Docker Image

Requirements: Docker + Docker Desktop are installed on your computer.

Docker image ( = a program) is basically a schema of Docker containers ( = running processes).

Fig 2: Docker Images and Containers, Source: https://jfrog.com/knowledge-base/a-beginners-guide-to-understanding-and-building-docker-images/

Building a Docker Image

Dockerfile is used for building a from a specific implementation. It specifies the following commands as below.

FROM <image-version> [AS <image-alias>]:

  • A parent image is fetched and used in the following commands.
  • Until next FROM command, the target image remains unchanged.

WORKDIR <path>:

  • The current working directory is changed to <path> inside a container.
  • It is linked to the nearest previous FROM command.

COPY [--from=<image-alias>|<image-version>] <src-path> <dest-path>:

  • It moves the specified file / folder from source directory / image to the destination path.
  • Same as WORKDIR, it is also linked to the previous FROM command.

--

--

Yamac Eren Ay

I love to write articles about the most underrated topics in computer science