Creating a base image

The way docker works is that you create images and you create running instances of these images by running them or by building them: running instances are containers. In general, there are two ways to create images.

Use the "run" or "pull" command to create a base image

Use a Dockerfile and the "build" command to create your own images

Both ways are important. You must understand the CLI commands - these will later be automated by the build agent - and because you must to use the Dockerfile to persist your image and automate building it later.

You may want to review the Docker practices for Images and Containers again before your start working with the CLI.

Create an image with the CLI

The CLI is the command line interface part of Docker Engine.

If you have docker installed, you can create a base image by opening a console and typing in:docker pull ubuntu if you don't have an Ubuntu image on your system, Docker automatically searches the the Docker Hub for the latest available image.

Achtung: Since you are just getting started this is ok. If you are working on a project where the application is only supported by ubuntu version 14.04 then you would pull that ubuntu image by specifying either the version or the release name in the tag - docker image pull ubuntu:trusty

The tag, that comes after the ":", contains the metainformation about the image. If there is no tag, Docker assumes that you want the latest image and pulls this.

Now, type in docker image ls

You should get a table of images. One of the columns in the table is "tag". If you pulled ubuntu: trusty, you will see trusty in the "tag" column.

CLI commands

ACHTUNG: As of release 1.13 Docker has added what appears to be "resource domains" to the CLI commands. The command domains serve the purpose of adding a new layer of "management" resources to the CLI (and assumedly, also the Docker API) so when you type - docker container <subcommand>- you know you are going to be managing containers and so on. The new resources add some complexity but are also a logical breakdown of docker resources. If You are running Docker 1.13.xx or later, please also get acquainted with these commands as well, you will need them in the future to form working requests to the Docker Daemon. If you have the newest Docker version open up a console and type in - docker- to get a look at these new commands.

Docker CLI resources are listed below. Follow the links in the table to take at Docker docs for resources and their subcommands. As always you can look at the man-page type documentation by typing docker <resource> on the command line of your console.

There are many more commands - like "docker network" - that may be useful to you as you develop with docker.

This is a getting started guide, but if you have already been using docker for a while you may also want to check any breaking changes that have been made to the Docker Engine and hence also the CLI. Docker lists all of their breaking changes for Docker Engine here.

CLI tutorials

Getting some practice with the CLI is good and here are some tutorials that step you through from basic commands to ssh-ing into the container itself to update software "in-container".

Achtung: These tutorials were made for the Docker Toolset, which is an older version of Docker for Windows. Still, you should be able to work through the tutorial. Just ignore the part about Boot2Docker. Also, for "Part 5", in the real Docker world, you do not want to work directly inside the container, you will want to configure these commands as instructions in your Dockerfile. More on that in the next section.