Containerizing Apps Using Docker
Learn how containerization can be done with Docker.
The Docker Engine is arguably the most popular containerization software today and is used by some of the biggest companies. The Docker Engine runs on a host VM and can create and run containers. These containers run in isolation, but underneath, they all share the same OS kernel and its resources.
So how can we go about Dockerizing our app? Let’s see.
How to create a Docker container for an app
Dockerizing an app involves writing something called a Dockerfile
. It's a simple text file with some Docker commands that:
Set the environment to enable compilation.
Compile the app source code.
Package the code and dependencies into one image.
Run that image.
Creating a Dockerfile
Let's see how we can create a Dockerfile
.
Setting up the environment
In order to compile our source code, we need to set up the environment. This means we need an OS that has Go installed on it.
Docker images are derivative, which means we can use a parent image. A parent image ...