Skip to content

Docker

Docker is a containerization technology that allows developers to package apps in images which can then be run as containers.

Docker concepts

Read this page: What is a container? A standardized unit of software

Images

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

In other words, a Docker image is the definition of a container. It is a file that lives in a Docker registry.

You can build a Docker image of your app by running the following command in the app's main directory. You need to have a Dockerfile available in that directory.

docker build -t IMAGE .

An image is defined by a 3-part name: [org/]app:tag

Some "official" Docker images such as php, nginx do not have a org prefix. Any image we create for ourselves or customers must include either the customer's name or our own as the org prefix, eg dzangolab/travelrecords.

The tag part of the name provides versioning. It usually follows semver conventions (major.minor.patch). A value of latest for the tag refers to the latest available version of the image.

Containers

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.

In other words, a Docker container is the runtime executable.

A Docker image becomes a container at runtime.

To run a container from an image, use the following command:

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Docker Engine

The Docker engine is the only runtime software required to run docker containers (and create docker images).

Registry

A Docker registry is a repository of Docker images. Dockerhub is a public Docker registry made available by Docker. Private registries are also available and can be self-hosted.

Useful resources

Assignments

Getting started with Docker

Complete the official 101-tutorial.

Run nginx server on port 80

Run nginx server via a container on default port 80. Use the latest official nginx image.

Run nginx server on port 8080

Run nginx server via a container on port 8080. Use the latest official nginx image.