From Zero to Microservice [2]
How to Dockerize Your App & Deploy using Kubernetes?
--
Previous articles:
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).
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 previousFROM
command.