Skip to content

Instantly share code, notes, and snippets.

Docker Cheat Sheet

Why

Why Should I Care (For Developers)

"Docker interests me because it allows simple environment isolation and repeatability. I can create a run-time environment once, package it up, then run it again on any other machine. Furthermore, everything that runs in that environment is isolated from the underlying host (much like a virtual machine). And best of all, everything is fast and simple."

TL;DR, I just want a dev environment

Keybase proof

I hereby claim:

  • I am ferrouswheel on github.
  • I am jpwp (https://keybase.io/jpwp) on keybase.
  • I have a public key whose fingerprint is 1183 6DAE 39D0 C262 DC7A 905C F151 CC60 5B54 C9AF

To claim this, I am signing this object:

# Copyright 2012 Erlware, LLC. All Rights Reserved.
#
# This file is provided to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
#!/bin/bash
sudo apt-get update
sudo apt-get -y install linux-image-extra-$(uname -r)
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get -y install lxc-docker
@ferrouswheel
ferrouswheel / README.md
Created October 7, 2015 23:12 — forked from clhenrick/README.md
PostgreSQL & PostGIS cheatsheet (a work in progress)
@ferrouswheel
ferrouswheel / readme.md
Created October 8, 2015 03:14
PostgreSQL FDW w/ PostGIS Support

FDW w/ PostGIS

The PostgreSQL native FDW (foreign data wrapper), postgres_fdw allows you to access tables from remote PostgreSQL servers very transparently, even doing thoughtful things like pushing restrictions to the remote server to reduce the amount of data transferred and ensure work is done close to the data.

Out of the box, the standard PostgreSQL FDW also allows PostGIS geometry to transit from remote to local hosts, which is pretty cool.

However, it will not push spatial restrictions from the local host to the remote host, only restrictions that relate to built-in types. I've done a rough and ready patch to the 9.4 branch to allow spatial restrictions to pass over FDW, and it is available here:

@ferrouswheel
ferrouswheel / move_to_github.sh
Created October 16, 2012 21:45
Script to move Opencog from Launchpad to Github
#!/bin/bash
# Destination must exist as empty repo on github
GIT_REPO="git@github.com:opencog/opencog.git"
TEMP_PATH=~/src/opencog_bzr_to_git
echo "Using $TEMP_PATH as working dir"
BRANCHES=(trunk UnityEmbodiment)
mkdir -p ${TEMP_PATH}
cd ${TEMP_PATH}
@ferrouswheel
ferrouswheel / image-credits.md
Last active December 8, 2015 01:01
Files related to Joel Pitt's Kiwicon 2015 talk on facial recognition and detection technology
@ferrouswheel
ferrouswheel / _base.html
Created March 3, 2013 23:12
Set up Django with CSRF protection when using require.js, backbone, and backbone-relational.
<script>
// Include this template in your base Django template.
// I also define my backbone API urls here, using Django's url resolver:
//var a_model_url = "{% url backbone:appname_modelname %}";
var csrf_token = "{{ csrf_token }}";
</script>
@ferrouswheel
ferrouswheel / to_local_time
Last active December 14, 2015 14:58
If you are using Django with USE_TZ=True, then Django stores times in UTC and various template utilities help to convert to the user's/current timezone as necessary. However, when serialising objects to JSON (which many API libraries do) they'll often directly convert the UTC time. This might be what you want, but you might also be using the API…
# assuming utc_datetime is the datetime to convert:
from django.utils import timezone
current_tz = timezone.get_current_timezone()
local_time = current_tz.normalize(utc_datetime).astimezone(current_tz)