Container Management with Docker

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Conclusion

The container principle is far from new. FreeBSD jails [22], Solaris Zones [23], OpenVZ [24] and LXC have existed for quite some time. Even the good old Linux chroot is nothing else in principle than a container. However, it looks like the makers of Docker bundled the right ideas into free software at the right time. (See the "Basic Commands" box for more information.)

Basic Commands

You can install Docker with the following command:

$ sudo apt-get update && apt-get install docker.io

Serious work with Docker also involves installing the following packages:

$ sudo apt-get install cgroup-tools dbootstrap rinse cgroupfs-mount aufs-tools

To run commands without root privileges, do:

$ sudo gpasswd -a <username> docker

To open an account, go to the Docker sign-up page [26], then register as a user:

$ docker login

Search for the desired image, for example, Debian:

$ docker search debian

There are currently 360 different Debian images in the Docker hub, requiring you carefully select the one that fits your needs. Each image is described in detail. For the test, the first image with the name debian should be enough.

$ docker pull debian

The image is then downloaded onto the local machine. Next, start the image in a container in the shell:

$ docker run -t -i debian /bin/bash

You can also simply load an image directly with docker run without using docker pull . The image will be fetched if it isn't available locally. Next, you'll see a prompt that shows something like:

user@70a1d73753b5:

The number after the name is the container ID.

$ user@70a1d73753b5: cat /etc/debian_version

should return 7.6 as the Debian version.

$ docker run -d ...

moves a container in the background.

$ docker ps

shows the running containers.

$ docker ps -a

shows all containers.

Use exit or Ctrl+D to exit from the container.

$ docker rm debian

removes the previously stopped container.

$docker rmi debian

removes the image.

Many more options are described in the Docker user guide [27].

Three operating systems have emerged around Docker, CoreOS, Red Hat's Atomic project and Dockerera, using the container technology for clusters and other expanded applications. As much as it seems like the conventional virtualization such as VirtualBox and VMware can't keep up with the speed and lower consumption, VMs aren't likely to go away any time soon. Thus for security reasons at Google, Docker containers run on virtual machines. Hundreds of containers can be distributed among a few VMs with twice the security.

Docker in VMs can also run under different platforms, as the Boot2docker project [25] has shown (Figure 13). The operating system ISO image is based on Tiny Core Linux with only 23MB that can be run in VirtualBox and also in Mac OS and Windows. It was designed for using Docker containers in other than Linux. Boot2docker is ideal for a first Docker test.

Figure 13: Boot2docker ready for deployment.

What's Ahead

Whether Docker will become more accessible to end users is yet to be seen. No doubt containers make sense also deployed on the desktop. You can use Docker to isolate less trusted programs or processes from the rest of the operating system. Tests with slightly altered conditions can be run in containers and compared with diff .

If you're occasionally building packages for your own use, you can depend on Docker as a build environment instead of chroot . Also, a user can build an operating system tailored to her needs from a base image, save it as a Docker image, and then publish it on the Docker hub. If you want to test Docker without much effort, consider Boot2docker. l

Infos

  1. Docker: https://docs.docker.com/
  2. Kubernetes: http://www.datacenterknowledge.com/archives/2014/07/10/googles-docker-container-management-project-kubernetes-gets-big-league-support/
  3. Hypervisor: http://en.wikipedia.org/wiki/Hypervisor
  4. Cgroups: http://www.linux-magazine.com/Issues/2011/130/Security-Lessons-cgroups-and-LXC/%28language%29/eng-US
  5. Namespaces: http://lwn.net/Articles/531114/
  6. LXC: http://en.wikipedia.org/wiki/LXC
  7. PaaS: http://en.wikipedia.org/wiki/Platform_as_a_service
  8. CVS: http://en.wikipedia.org/wiki/Concurrent_Versions_System
  9. SaaS: http://en.wikipedia.org/wiki/Software_as_a_service
  10. aufs: http://en.wikipedia.org/wiki/Aufs
  11. Device mapper: http://en.wikipedia.org/wiki/Device_mapper
  12. Btrfs: http://en.wikipedia.org/wiki/Btrfs
  13. Filesystems: http://www.projectatomic.io/docs/filesystems/
  14. Project Atomic: http://www.projectatomic.io/
  15. Base image: https://docs.docker.com/terms/image/#base-image-def
  16. Git: http://en.wikipedia.org/wiki/Git_(software)
  17. Dockerfile: https://registry.hub.docker.com/u/toke/owncloud7/dockerfile/
  18. Docker 1.2: http://blog.docker.com/2014/08/announcing-docker-1-2-0/
  19. Panamax: http://panamax.io/
  20. Vagrant: https://www.vagrantup.com/downloads.html
  21. VirtualBox: https://www.virtualbox.org/wiki/Downloads
  22. FreeBSD jail: http://en.wikipedia.org/wiki/FreeBSD_jail
  23. Solaris Zones: http://en.wikipedia.org/wiki/Solaris_Containers
  24. OpenVZ: http://en.wikipedia.org/wiki/OpenVZ
  25. Boot2docker: http://boot2docker.io/
  26. Sign up for Docker: https://hub.docker.com/account/signup/
  27. Docker user guide: http://docs.docker.com/userguide/

Buy this article as PDF

Express-Checkout as PDF

Pages: 5

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content