How to limit the docker log size?

Have you given a surprise after a month or two that all the space in your server is filled with docker logs? Do you know that if you don’t control the size of the log, it will also impact running containers?

These two problems can be resolved easily by configuring the docker container. It is preferred that you control each log size separately because some logs you don’t need much while some you do.

For instance, in case of Nginx/Apache you might want to keep more logs while for some less relevant applications like emailing, you might want to keep logs for only a few days.

version: "3.8"
services:
  nginx:
    image: nginx
    logging:
      driver: "json-file"
      options:
        max-size: "20m"
        max-file: "30"

This will ensure that at max, you will have 30 files and each file size will be a maximum of 20 megabytes. You can use 20k for kilobytes

Worth Sharing?

How to install GVM and latest Go (One-Liner)?

The gvm a.k.a. Go Version Manager is an excellent tool to maintain multiple version of Go in your system.

Instruction

If you are using zsh

Assuming that latest go at the moment is 1.14.4 and you are using zsh

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) \
      && echo "source /home/$USERNAME/.gvm/scripts/gvm" >> ~/.zshrc && source ~/.zshrc \
      && gvm install go1.4 -B && gvm use go1.4 --default \
      && gvm install go1.14.4 && gvm use go 1.14.4 --default

If you are using bash

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) \
      && echo "source /home/$USERNAME/.gvm/scripts/gvm" >> ~/.bashrc && source ~/.bashrc \
      && gvm install go1.4 -B && gvm use go1.4 --default \
      && gvm install go1.14.4 && gvm use go 1.14.4 --default

The above one liner works with Ubuntu as well as Debian.

Explanation

First line (below) will install gvm.

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

Second line will ensure loading of gvm in your shell and it will load shell configuration again for this instance

echo "source /home/$USERNAME/.gvm/scripts/gvm" >> ~/.bashrc && source ~/.bashrc

Third line will install the go version without source (-B is for Binary) which will be loaded then as default

gvm install go1.4 -B && gvm use go1.4 --default

Fourth line will install the go specified version with source and compile it using go1.4

gvm install go1.14.4 && gvm use go 1.14.4 --default

Worth Sharing?

How to stress test your CPU?

At the moment, I am using Ubuntu. It has an amazing package which is stress to give some stress testing to your new machine. Like any other stress testing, idea here is to simply make sure that your machine is running at its full capacity and you are going to observe the temperature of CPU as well as the fan’s rpm.

Install stress

sudo apt-get install stress -y

Command

stress --cpu $(grep -c ^processor /proc/cpuinfo) --timeout 60

The grep -c ^processor /proc/cpuinfo will just tell you how many cpu cores are there. This will spawn that number of cpus.

Worth Sharing?