Docker basics¶
Resource isolation features make it possible for the containers to shareunderlying operating system resources. Whereas more traditional virtualmachines replicate an entire operating system, containerisation can provide amuch more lightweight solution to virtualisation, containing only the specificstack layers required for a particular application.
Docker containers are thus smaller and consume fewer resources, avoiding thememory and CPU overheads of full virtualisation. They are faster to start up,manage and scale, and easier to move, around than full virtual machines.
This can be done in two ways:
(On Macintosh, it’s provided by through HyperKit, a lightweightvirtualisation system built on top of the Hypervisor.framework (macOS10.10 Yosemite and higher).
- On older systems, it requires a Linux virtual machine running in VirtualBox. This is managed by a tool called Docker Toolbox.
The two key components in Docker are:
- Docker Compose (invoked as docker-compose) is a tool for defining andmanaging multi-container applications.
See for the basics of anddocker-compose
usage.
- Application
Docker terminology uses “application” in much the same way that Django uses“project”, a collection of components that together form a complete andself-contained system.
In our case, a Docker application is the collection of components that isresponsible for a website and its functionality, including everything fromthe database to the frontend code.
Docker applications are typically managed using Docker Compose, and configured in a file.
A Docker application will typically include multiple containers.
- Container
- A Docker container is virtualised application environment. Unlike a virtualserver, it doesn’t need to provide every layer in a full working system.Instead, it encapsulates only the layers required to run an application.
- Image
- An image is a template. Each container is based on an image. Once an imagehas been created, each container created from it will provide exactly thesame environment, and the applications in it will behave identically. Animage is defined by its Dockerfile.