cloud hosting companies

May 31, 2017

7 min read

Five cool (and impractical) things to do with Docker

Written by

Vippy The VPS

If you’re part of our containers preview, you’ll have access to Docker, the container-based software that’s had people buzzing for years, now. Once you’ve gone through the installation and configuration process, you’re ready to start doing some really cool things with your VPS that are only possible because of containers.

Some of these are wildly impractical, others are exceedingly so, and some are simply experiments that we’d love to see others push to new heights.

1. Create highly disposable dev/testing environments

We know that many SSD Nodes customers use their VPSs as a place to test software and learn new things in a clean environment that won’t mess up their main machine. A VPS is a pretty cheap and effective educational tool if someone wants to know more about Linux administration or the fundamentals of deploying code to a production server.

But it can also be a pain to repeatedly rebuild your VPS and start clean because, while experimenting, you made some change that breaks everything. Instead, why not use Docker to create a highly disposable, isolated environment to play around in?

Take the xeyes Dockerfile from above and expand it until you’ve created a development environment that’s to your exacting standards. Choose the base OS, the software you want to install (vim or emacs or nano, anyone?), and build the image with docker build -t mydev, replacing mydev with any name you’d like. Then, you can spin up as many instances as you want with docker run -it mydev, which will kick you right into a shell to get started.

If something goes terribly wrong inside the container, simply disconnect and destroy it.

2. Run Docker inside of Docker

A visualization of dind, courtesy of Jérôme Petazzoni
A visualization of dind, courtesy of Jérôme Petazzoni

Thanks to Jérôme Petazzoni, a senior engineer at Docker, it’s possible to run a Docker container inside of another Docker container. Even after about 4 years, there’s still very few good reasons for why you would want to do this, except to say that you you did, although some seem to have experimented with running a container for a CI system like Jenkins, which spawns yet more containers.

Check out the dind repository for more information. Or, just run a single command to get nesting:

$ docker run --privileged -d docker:dind

3. Containerize desktop apps

xeyes through Docker through X11
xeyes through Docker through X11

Remember that tutorial we put together a few weeks ago about running GUI applications on your VPS via X11 forwarding? Well, it’s possible to also forward X11 applications that are running inside a Docker container, thanks to some enterprising work by Alan Hohn at DZone.

First, remember to connect to your VPS using the -XC options for ssh, and then create a new directory, and a Dockerfile inside of it. This assumes you’ve also enabled X11Forwarding—more on that in the link above.

$ ssh -XC USER@YOUR-SERVER-IP
$ mkdir xeyes && cd xeyes
$ nano Dockerfile

This is a very basic Dockerfile that will create a Docker image called xeyes that contains only the bare essentials for running the command.

FROM centos
RUN yum install -y xeyes
CMD ["/usr/bin/xeyes"]

Then, you can build the Docker image.

$ docker build -t xeyes .

Finally, give it a whirl. xeyes should appear on your local desktop.

$ docker run --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" xeyes

It should be possible to run more complex GUI applications via Docker, but I was unable to get much of anything working right off the bat. Still an interesting thing to experiment with, perhaps.

4. Monitor Docker with Docker

The docker-mon interface
The docker-mon interface

So, even if you don’t want into Russian doll territory by running containers inside of containers, you can still leverage the power of Docker to keep tabs on other containerized software thanks to docker-mon.

This application, which can be installed in a single command using Docker itself—docker run -ti -v /var/run/docker.sock:/var/run/docker.sock icecrime/docker-mon—lets you scroll through a list of currently running containers, and then offers a live view into the CPU/memory/network usage. Detailed information about the container configuration can help you debug issues or easily discover information you need elsewhere.

5. Monitor Docker with Minecraft?

Stopping, destroying, and starting containers with Minecraft
Stopping, destroying, and starting containers with Minecraft

That famous 3D interface from the original Jurassic Park has finally met its match. Thank Docker itself for creating this oddity of a visualization and management tool for Docker containers. Inside of the Minecraft world, you can start and stop containers with the flip of a switch, destroy them, and start up new ones using the command line.

It’s certainly not practical, but, like most things Docker-related, it’s pretty easy to install and get running. Head on over to the Github repository to learn more.

Even more cool, useful, and strange Docker uses

If you’re looking for more, check out the awesome-docker repository on Github, which contains a list of Docker-based tools and potential use cases broken down by category. We’d also love to hear about what our preview customers have gotten up to over the long weekend—what’s your favorite feature, or your favorite new tool? Let us know in the comments.

Leave a Reply