Chapter 3. Using Docker as a lightweight virtual machine

 

This chapter covers

  • Converting a virtual machine to a Docker image
  • Managing the startup of your container’s services
  • Saving your work as you go
  • Managing Docker images on your machine
  • Sharing images on the Docker Hub
  • Playing—and winning—at 2048 with Docker

Virtual machines (VMs) have become ubiquitous in software development and deployment since the turn of the century. The abstraction of machines to software has made the movement and control of software and services in the internet age easier and cheaper.

Virtual machines

A virtual machine is an application that emulates a computer, usually to run an operating system and applications. It can be placed on any (compatible) physical resources that are available. The end user experiences the software as though it were on a physical machine, but those managing the hardware can focus on larger-scale resource allocation.

Docker isn’t a VM technology. It doesn’t simulate a machine’s hardware and it doesn’t include an operating system. A Docker container is not by default constrained to specific hardware limits. If Docker virtualizes anything, it virtualizes the environment in which services run, not the machine. Moreover, Docker can’t easily run Windows software (or even that written for other UNIX-derived operating systems).

3.1. From VM to container

Technique 10 Converting your VM to a container

Technique 11 A host-like container

Technique 12 Splitting a system into microservice containers

3.2. Managing services on your containers

Technique 13 Managing the startup of your container’s services

3.3. Saving and restoring your work

Technique 14 The “save game” approach to development

Technique 15 Docker tagging

Technique 16 Sharing images on the Docker Hub

Technique 17 Referring to a specific image in builds

3.4. Environments as processes

Technique 18 The “save game” approach to development

3.5. Summary

sitemap