Docker Quick Tutorial

Docker Quick Tutorial

Docker is a collection of platform as a service (PaaS) products that use operating-system-level virtualization to deliver software in packages called containers. Containers are fully isolated from each other and are a standard unit of software that packages up code and all of its dependencies so the application runs quickly and reliably from one computing environment to another. This makes containers a great tool for reproducing development environments, as well as serving reproducible applications in production. In this quick tutorial, we’ll get started with Docker.

Install Docker for your OS.

We’ll be using Docker for Windows and the Docker docs show you how to Install Docker Desktop on Windows here.

Download Docker

Launch Docker and Begin The Tutorial

After the install completes you will be given the option to complete a tutorial, and that is what you should do straight away.

0 Get started with docker easy steps

Clone A Repository

In order to launch a container we first need to clone a repository from Github. If you’re new to Git you can check out the Git For Beginners tutorial to become familiar. The Getting Started project is a simple GitHub repository which contains everything you need to build an image and run it as a container.

git clone

1 docker clone a repository

Build The Image

A Docker image is a private file system just for your container. It provides all the files and software your container needs.

cd getting-started
docker build -t docker101tutorial

2 docker build image after clone repo

Run A Container

Start a container based on the image you built in the previous step. Running a container launches your application with private resources, securely isolated from the rest of your machine.

docker run -d -p 80:80 --name docker-tutorial docker101tutorial

3 docker run your first container

(Optional) Sign Up With Docker Hub

Docker hub is a wonderful resource for you to find literally any software in the world to run in your containers.
Access the world’s largest library of container images!

4 docker save image to docker hub optional

View Container In Dashboard

In the Docker Dashboard, you will see the container up and running with a few options. We can click the View in Browser option to see the fruits of our labor.

5 docker container image now running

Your Web Browser should launch automatically and navigate to http://localhost/tutorial, which is the running application that you just launched on your local machine using Docker!

docker tutorial application running

The tutorial included in the newly launched app is superb. It covers everything you need to know, and will likely answer a lot of questions you may have, especially if you are coming from a virtual machine workflow background. The following topics are covered:

Docker Quick Reference

Congratulations, you got your first container up and running. The following is a nice reference for quickly using available Docker commands.

docker build

Build an image from the Dockerfile in the current directory and tag the image
docker build -t myimage:1.0 .

List all images that are locally stored with the Docker Engine
docker image ls

Delete an image from the local image store
docker image rm alpine:3.4

docker run
Run a container from the Alpine version 3.9 image, name the running container “web” and expose port 5000 externally, mapped to port 80 inside the container.
docker container run –name web -p 5000:80 alpine:3.9

Stop a running container through SIGTERM
docker container stop web

Stop a running container through SIGKILL
docker container kill web

List the networks
docker network ls

List the running containers (add –all to include stopped containers)
docker container ls –all

Delete all running and stopped containers
docker container rm -f $(docker ps -aq)

Print the last 100 lines of a container’s logs
docker container logs –tail 100 web

docker share
Pull an image from a registry
docker pull myimage:1.0

Retag a local image with a new image name and tag
docker tag myimage:1.0 myrepo/myimage:2.0

Push an image to a registry
docker push myrepo/myimage:2.0

Docker Management

  • docker app – Docker Application
  • docker assemble* – Framework-aware builds (Docker Enterprise)
  • docker builder – Manage builds
  • docker cluster – Manage Docker clusters (Docker Enterprise)
  • docker config – Manage Docker configs
  • docker context – Manage contexts
  • docker engine – Manage the docker Engine
  • docker image – Manage images
  • docker network – Manage networks
  • docker node – Manage Swarm nodes
  • docker plugin – Manage plugins
  • docker registry – Manage Docker registries
  • docker secret – Manage Docker secrets
  • docker service – Manage services
  • docker stack – Manage Docker stacks
  • docker swarm – Manage swarm
  • docker system – Manage Docker
  • docker template – Quickly scaffold services (Docker Enterprise)
  • docker trust – Manage trust on Docker images
  • docker volume – Manage volumes

Learn More About Docker

Docker Quick Tutorial Summary

This should give you a basic understanding of how Docker operates with a grasp of the key Docker concepts. At its most basic level, Docker is simply images and containers. Learning how to leverage these technologies is a huge benefit to software developers, small businesses, and fortune 500 companies alike.