Installing

Visit Docker's documentation installing Docker engine on Ubuntu for instructions on how to install the very latest version, including the Docker GPG keys. You can also install Docker from Ubuntu's own package repositories via

sudo apt install docker.io

Images and Containers

With Docker you create and manage images and containers. Images are templates for runtime environments. Containers are created (instantiated) from images. Each container is an independent environment in which your software product executes. Containers can be used by servers to handle requests from multiple clients in isolated environments. Containers are also useful in software development, where the software is built and tested in discardable containers created from images of fully specified build and run environments.

Dockerfile

The environment inside of a Docker image is defined by the instructions that the Docker image builder picks up from a file. The default expected name for this file is Dockerfile. If your Dockerfile has a different name, you need to provide that file name to the build command:

docker build -t MyImage -f /path/to/MyDockerFileName


The Dockerfile Reference describes the commands that can be issued in a Dockerfile

Docker Compose

Docker Compose takes the role of the Docker command line interface and lets you send commands to the Docker engine by elegantly specifying a build/run configuration in a YAML file instead of, e.g., creating a shell script with Docker CLI commands. For example, the following Docker commands for building an image and instantiating a container

docker build -t my-app .
docker run --rm -tip 3000:3000 -n my-app my-app

can be be expressed by this docker-compose.yml file:

version: "3.8"
services:
  app:
    build: ./
    ports:
      - 3000:3000


The configuration defined in the YAML file is then realized with the command

docker-compose up --build

where the --build option triggers a rebuild of the image. Note also that docker-compose automatically removes containers that have exited.


Debug data: