Your First Docker Container
Everyone is talking about Docker these days. Why another virtualization-thing? Why should I bother, am happy with Bento and Vagrant?
I needed answers. The best way to get them is to get a feel for the tool by installing and playing around with it.
This post will bring you up-to-speed in using Docker as fast as possible and provide you some further pointers.
Before your first installation I recommend doing this interactive tutorial.
Installation #
On my Mac, I basically had two options installing Docker, either with boot2docker or in any other virtual machine, because there is no native way to install it on Mac OS X.
At first, I have tried boot2docker but soon ran into limitations (no volumes) and switched to a Vagrant box that I have build as described here.
When the Vagrant box was up I did the following:
{% highlight none %} yum -y install docker service docker start chkconfig docker on docker run -i -t centos /bin/bash {% endhighlight %}
Congratulations! You are now in a shell of your first docker container.
That was all? Yes!
What’s Next? #
Visit Docker Hub to find the docker image that fits your needs.
As an alternative start building your own docker images. Watch this blog, I have already drafted the next blog post that will explain how to build a custom image.
Take Aways #
Key take-aways while surfing the web for information and specific use-cases:
- A container does not get configured during run-time. A new image will be build reflecting that configuration change and the current container will be replaced with a new container from that image.
- A container does just one thing and not more, e.g. provides a database, is a web server, but not being a database and a web server at the same time.
The very most-important key-point which made my virtualization universe whole again:
- When to use what? - When abstracting a machine, use Vagrant. When abstracting an application, use Docker. Yay!
Further Reading #
- Solomon Hykes explains Docker
- Interactive Tutorial
- What is docker?
- Some Docker Tips and Tricks
- Should I use Vagrant or Docker.io for creating an isolated environment?
Done for today!