Running Docker without sudo

After installing docker on linux you might find that you have to run all docker commands with sudo. It is possible to add your username to the docker group so that you can run Docker without using sudo:

sudo usermod -a -G docker ${USER}

You may need to log out and back in for it to take effect.


Adding gzip compression to a Rancher HAProxy Load Balancer

Adding gzip compression to a Rancher HAProxy Load Balancer

Say you want to gzip application/json coming from your application you can put a Rancher Load Balancer (HAProxy) in front and add the following config to the defaults section:

compression algo gzip
compression type application/json

This will then gzip all responses with Content-Type: application/json if the client supports compression.

A simple benchmark suggests that doing it at the LB instead of within the application is more performant than, say, using the compression middleware in a node.js express application

For a more complete set of MIME types which can be compressed, use this:

compression type text/html "text/html; charset=utf-8" text/html;charset=utf-8 text/plain text/css text/javascript application/x-javascript application/javascript application/ecmascript application/rss+xml application/atomsvc+xml application/atom+xml application/atom+xml;type=entry application/atom+xml;type=feed application/cmisquery+xml application/cmisallowableactions+xml application/cmisatom+xml application/cmistree+xml application/cmisacl+xml application/msword application/ application/ image/svg+xml

Restore a mongodump with mongo restore

Extract the .tar.gz file created by mongodump. dump is the default folder name.

In mongodb 3.0 or above you need to specify the database name to restore to with the -d flag:

mongorestore -d [your_db_name] [your_dump_dir]