Docker stop and remove all active containers

docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)

MySql select from nested query with max date constraint

Example of MySql select from nested query with max (or min) constraint.

SELECT company_id FROM (
	SELECT co.company_id, DATE(tsk.modified) mm
        FROM company co
        LEFT JOIN project p ON p.company_id = co.company_id
        LEFT JOIN task tsk ON tsk.project_id = p.project_id
        WHERE 1
            AND < 1
            AND co.pay_status < 0
            AND co.test_account < 1
) AS tmpt
GROUP BY company_id
ORDER BY `tmpt`.`company_id`  DESC

Docker pass term env to container with exec

Sometimes you need quick interactive access to a container that doesn’t have the TERM environment set, so you can pass it via something like this:

docker exec -ti mysql env TERM=xterm mysql -u mysqluser

Mongo db admin – node.js app

MongoExpress is a nice little basic app for monitoring and managing MongoDB (view, edit, export, etc.).

docker run -d --name=mongoexp -p 8081:8081 -m 400M --link mongo:meteor-db mongo-express

install VirtualBox Guest Additions & mount shared folders

To use Guest Additions on a VirtualBox VM you need to install Guest Additions from the VBoxGuestAdditions.iso.

On Ubuntu/Debian, you should install additional system tools first if you don’t already have then:

apt-get update
apt-get install dkms build-essential linux-headers-$(uname -r)

First use the VB app to set up the share and then “insert” the virtual CD via the VB storage settings menu drop-down, then:

mount /dev/cdrom /mnt
cd /mnt
./ --nox11


mount | grep vbox

to verify the share path, etc.

Alpine Linux with Docker – node build tool updates

Smaller distros like Alpine for containers just seems to make sense.

Some build tools for node.js include:

apk --update add bash nano wget python make gcc g++

You can install on a “build” container and create an artifact to transfer to a sparse box without the build tools. See base images like:

« Previous Entries