Dockers Concepts

Official Definition

Docker is an open platform for developers and sysadmins to build,ship and run distributed applications

Docker’s philosophy is “build->ship->run”.

In contemporary IT industry, there are two major usage of Docker.

  1. Focus on Build & Ship, to leverage Docker to setup a platform of “CI/CD”, for develop, test enviornment.
  2. Make use of Docker as light weight VM (virtual machine), focus on Run, apply it in large scale production environment.

ACL

the access control in docker is rely on iptables, the firewall software shipped in almost all Linux release.

Sample Commands

List all images

1
docker images
1
sudo docker version

remove all exited containers

docker rm $(docker ps -a -f status=exited -q)

Run

1
2
docker run IMAGE_NAME [COMMAND] # run a command in new container
docker run -t -i f2d8ce9fa988 /bin/bash # run bash in console and interactive mode

View docker details, e.g. start up script, working dir

1
docker inspect containerid

Start bash to view files inside docker

1
docker -t -i imageFile /bin/bash

Map hosts between host and contains

1
2
docker -P xxx
docker ps -l

You’ll see

1
0.0.0.0:32768->5000/tcp

It means host port 32768 map to port 5000 in contains

To list docker containers including histories

1
2
docker ps -a # show all containers instead of only running as default
docker ps -l # show latest created container

removes containers once return from one run

1
docker run --rm -name myApp1  -link  db:db training/webapp env

to ping other containers

Be advised there is no built-in ping for containers, therefore it’s requried manually install one. As following sample:

1
apt-get install -yqq inetutils-ping

Links