Docker.io and Redis on DigitalOcean in Five Minutes
It all started when I casually spotted a sponsored tweet offering me $10 worth of virtual computing power from DigitalOcean. I had seen their ads on everything from Facebook to Gmail and thought I’d check out what the fuss was about.
I had been planning to try Docker.io on something other than my MacBook for a while and was tempted to run up another Linode server. Instead, I decided to see if I could get Docker running on DigitalOcean.
Docker turned 0.6 over the weekend and is heading full speed toward a production-grade container platform. If you are reading this post you are probably already interested in Docker, but for the uninitiated, Docker allows you to ship applications as containers running in what appears to be self-contained Linux environments. It's is based on Linux container magic and runs within the same operating system as its host.
So here is my guide to get Docker 0.6.1 running on the DigitalOcean VM. Five minutes starts now!
First, create a new droplet based upon the Ubuntu 13.04 x64 image
Once it is created, SSH directly on to the box as root. For me it was as simple as:
Now, following Docker’s install guide, I ran:
apt-get update apt-get install linux-image-extra-`uname -r` sh -c "curl http://get.docker.io/gpg | apt-key add -" sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" apt-get update apt-get install lxc-docker
Which allowed me to run Docker for the first time.
root@blog:~# docker version Client version: 0.6.1 Server version: 0.6.1 Git commit: 5105263 Go version: go1.1.2 Last stable version: 0.6.1
Now, to run something exciting, let's run Redis.
docker run -d johncosta/redis
Install redis-cli on the host machine.
apt-get install redis-server redis-cli -h 18.104.22.168 -p 6379
Or connect from your MacBook.
brew install redis redis-cli -h 22.214.171.124 -p 6379
Now, it's time to play with Redis.
redis localhost:6379> set docker magic OK redis localhost:6379> get docker "magic"
Five minutes must be up by now!