Change default Docker location

By default, Docker will store its data in /var/lib/docker. Sometimes it’s needed to change this location. There are several ways to do it. The easiest is to create the following file: /etc/systemd/system/docker.service.d/docker-storage.conf [Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// –graph=”/home/docker” Then you just need to refresh systemctl, make sure your folder exists and restart docker: mkdir -p /home/docker systemctl daemon-reload systemctl stop docker systemctl start docker No restart needed.

Install Docker on Ubuntu/Debian

Install some prerequisites: apt-get update apt-get install apt-transport-https ca-certificates curl software-properties-common Add Docker’s official GPG key: curl -fsSL | sudo apt-key add – Add the repository: add-apt-repository \ “deb [arch=amd64] \ $(lsb_release -cs) \ stable” Install Docker: apt-get update apt-get install docker-ce Try “docker info”, “docker version” or “docker ps -a” to check, once it’s installed.

Cleanup old docker volumes and images

Remove old images: docker images -q –no-trunc –filter dangling=true | xargs –no-run-if-empty docker rmi -f Delete all dangling volumes: docker volume ls -qf dangling=true | xargs –no-run-if-empty docker volume rm On newer Docker versions: docker image prune docker volume prune Or clean all in one command: docker system prune

Installing Cobbler 2.6.11 on Ubuntu 16.04

As it took me a bit to figure out, I'll quickly show in this tutorial how to install the latest version of Cobbler on Ubuntu. It may work in a quite similar way also on other linux distributions. First install the prerequisites: apt-get update apt-get install python python2.7 python-django python-netaddr python-yaml python-simplejson python-cheetah python-libvirt python-urlgrabber apache2 libapache2-mod-wsgi make Apache needs the proxy module enabled: a2enmod proxy proxy_http Now download cobbler and install it: wget Read more…

Getting replication lag in PostgreSQL

Here a 2 simple queries to get the replication lag on Postgres servers: select now() – pg_last_xact_replay_timestamp() as lag; select pg_last_xlog_receive_location() receive, pg_last_xlog_replay_location() replay, ( extract(epoch FROM now()) – extract(epoch FROM pg_last_xact_replay_timestamp()) )::int lag;

Rsync using sudo over SSH

If you can ssh to a remote server using your public key, but want rsync to be executed as a different user, you can achieve it like this: On the remote host add an entry in /etc/sudoers which looks like this (replace the username accordingly): user1 ALL=NOPASSWD: /usr/bin/rsync * This will allow your user account user1 to run rsync commands via sudo once he's logged in. Then run rsync like this (change paths accordingly): rsync Read more…

Testing if a server port is actually open

There are actually a whole lot of possibilities to do that, the most simple one probably to use a simple telnet: telnet 80 Or the good old nmap: nmap -sS -O -p80   In a Bash script you can simple do it this way: #!/bin/bash test=$(nc -z -v -w1 80 2>&1) if [[ $test == Connection*succeeded* ]]; then # put your code here fi   A simple Ruby script could look like this: #!/usr/bin/ruby require 'socket' require Read more…