Five cool (and impractical) things to do with Docker
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.
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.
Get THE BEST DEALS IN CLOUD HOSTING from Los Angeles!Grab a huge 32GB RAM & 320GB of SSD storage for just $109/year!
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?
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 (
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.
|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
|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 [email protected] 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.
|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
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.
|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.
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.