What is Docker?

By Xah Lee. Date: . Last updated: .
docker logo
Docker logo.

Docker is basically a software container layer that lets you run a app of many components (database, server, frameworks, etc.) as if you are running one single software.

Docker is like a virtual machine, but without the OS component. Here's a picture.

whats docker
What's docker. (from https://www.docker.com/whatisdocker/)
Introduction to Docker, by founder Solomon Hykes.
Docker Tutorial - What is Docker and Docker Containers, Images, etc?

docker official site: https://www.docker.com/

Docker is written in golang.

Docker Tutorial

Docker Engine has 2 parts: (1) a server (daemon). (2) a client, that controls the server.

docker help
List commands.
you@tutorial:~$ docker help
Usage: Docker [OPTIONS] COMMAND [arg...]
-H="127.0.0.1:4243": Host:port to bind/connect to

A self-sufficient runtime for linux containers.

Commands:

attach    Attach to a running container
build     Build a container from a Dockerfile
commit    Create a new image from a container's changes
diff      Inspect changes on a container's filesystem
export    Stream the contents of a container as a tar archive
history   Show the history of an image
images    List images
import    Create a new filesystem image from the contents of a tarball
info      Display system-wide information
insert    Insert a file in an image
inspect   Return low-level information on a container
kill      Kill a running container
login     Register or Login to the Docker registry server
logs      Fetch the logs of a container
port      Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
ps        List containers
pull      Pull an image or a repository from the Docker registry server
push      Push an image or a repository to the Docker registry server
restart   Restart a running container
rm        Remove a container
rmi       Remove an image
run       Run a command in a new container
search    Search for an image in the Docker index
start     Start a stopped container
stop      Stop a running container
tag       Tag an image into a repository
version   Show the Docker version information
wait      Block until a container stops, then print its exit code
docker version
Show the docker server and client version number.
you@tutorial:~$ docker version
Docker Emulator version 0.1.3

Emulating:
Client version: 0.5.3
Server version: 0.5.3
Go version: go1.1

A docker packaged app is called a “docker image” (as in “disk image”)

docker images are hosted at “Docker Hub Registry” (as in “github”) at https://registry.hub.docker.com/

docker search name
Search docker images.
docker run image_name command
Run command in docker images named image_name.

when a command is run in a container, the container is said to “started”. Once the process finishes, the container “stopped”.

Example:

docker run niceHome/myNiceApp echo "love you"

to install programs in a container, do:

docker run learn/tutorial apt-get install -y ping

changes in a container needs to be saved. To save, run docker commit

you@tutorial:~$ docker ps -l
ID                  IMAGE               COMMAND                CREATED             STATUS
   PORTS
6982a9948422        ubuntu:12.04        apt-get install ping   1 minute ago        Exit 0
docker commit 6982a9948422
you@tutorial:~$ docker commit
Usage: Docker commit [OPTIONS] CONTAINER [REPOSITORY [TAG]]

Create a new image from a container's changes

  -author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
  -m="": Commit message
  -run="": Config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "Port
Specs": ["22"]}')

docker commit container_id new_name

docker inspect image_id
Show info.
docker images
List images on the host.