Skip to content

Instantly share code, notes, and snippets.

View arvind-india's full-sized avatar

Arvind Singh arvind-india

  • Bangalore
View GitHub Profile
@arvind-india
arvind-india / docker-cleanup-resources.md
Created August 10, 2017 22:18 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@arvind-india
arvind-india / gist:7513b931ac27ceef9d646b93942224d7
Created August 10, 2017 21:37 — forked from carmark/gist:4aa32cacd4d041448c39ad8deb87135f
A sample Docker workflow with Nginx, Node.js and Redis

For this example, I have a very simple Node.js applications that increments a counter stored on Redis. I want to run Redis and the node application independently as I want to have the ability to scale the node application depending on the load. To start off, I have 3 instances of the node server running the application. I have an Nginx server in front of node for load balancing the node instances.

Let’s now talk in terms of containers, specifically Docker containers. Simple; 1 container for each service/process!

  • 1 Redis container
  • 3 Node containers
  • 1 Nginx container So, the overall picture looks something like this:

#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@arvind-india
arvind-india / cc2650.py
Created August 3, 2017 13:15 — forked from jpmens/cc2650.py
CC2650 read via BLE and publish to MQTT
#!/usr/bin/env python
# read CC2650 SensorTag by JP Mens
# follow https://smidgeonpigeon.wordpress.com/2015/07/21/raspberry-pi-2-ble-ti-sensor-tag/
# to get started, but use Sensortag2650.py
import time
import json
import struct
import Sensortag2650 as sensortag
import paho.mqtt.publish as mqtt
@arvind-india
arvind-india / node-red-sensortag.js
Created April 12, 2017 12:44 — forked from LosantGists/node-red-sensortag.js
Node-RED function node to combine SensorTag messages into single payload.
// This function node combines all of the async values
// reported by the sensor tag node into a single
// payload. The flow will only continue when all values
// have been received.
var payload = context.get('payload') || { data: {} };
// Number of total attributes to report.
// When we collect all attributes from the
// sensor tag, the flow will continue.