Docker

Use Multi-Stage Builds to Improve Continuous Delivery Pipeline

Learn how to use Docker multi-stage builds

ta-ching chen

3 minute read

Introduction

A basic rule for building a container image is “the smaller is better”.

But it’s not an easy job for the compiled language (e.g. go, java) due to large build environment and dependencies. In the post “Building Minimal Docker Image for Go Applications”, we need to produce a go binary first and put it into scratch image. And it’s quite complicated and heavy for developers to create such continuous delivery pipeline.

To solve this problem, Docker 17.05+ releases a new feature called Multi-stage builds. With this feature we can combine multiple dockerfiles into one and let base image to copy artifacts and outputs from the intermediate image. In this way, we can keep pipeline easy to read and maintain.

Check Containers Status with Ctop

Use Top-like way to check containers information

ta-ching chen

1 minute read

Introduction

It’s not easy to check containers status with top/htop. With ctop, now we can check/display all containers status with top-like interface!

Installation

ctop is developed by Go, all we need to do is download and put binary to the right place, then we can start to monitor containers status! (Support Linux and macOs)

Linux

$ wget https://github.com/bcicen/ctop/releases/download/v0.4.1/ctop-0.4.1-linux-amd64 -O ctop
$ sudo mv ctop /usr/local/bin/
$ sudo chmod +x /usr/local/bin/ctop

Building Minimal Docker Image for Go Applications

Learn how to build tiny docker image for Go from scratch

ta-ching chen

2 minute read

Hello World

Lets create a simple small application that keeps printing out Hello World!

// main.go
package main

import (
    "fmt"
    "time"
)

func main() {
    for {
        fmt.Println("Hello World!")
        time.Sleep(1 * time.Second)
    }
}