I. Images Operation

1. Pull a Image

# pull latest
docker pull centos
docker pull centos:latest

# pull specific version tag
docker pull centos:7

2. List Images

docker images

## filter by repo
docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mongo               3.6                 3fa64d9ee5ad        6 days ago          436MB
mysql               latest              d435eee2caa5        2 weeks ago         456MB
centos              7                   5e35e350aded        4 weeks ago         203MB
ubuntu              latest              775349758637        5 weeks ago         64.2MB
centos              latest              0f3e07c0138f        2 months ago        220MB

docker images centos
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              7                   5e35e350aded        4 weeks ago         203MB
centos              latest              0f3e07c0138f        2 months ago        220MB

3. Remove a Image

docker rmi <image_tag>
docker rmi <image_id>

# remove all images
docker rmi $(docker images -q)

II. Containers Operation

1. List Containers

# list running containers
docker ps 

# list all containers
docker ps -a

2. Run a Container

# run with a random name
docker run centos

# run with a specific name
docker run --name <container_name> centos

# run interactively(-i for interactive, -t for terminal)
docker run -it centos

# run a specific image
docker run centos:7

# run an exited container
docker start <container_name>
docker attach <container_name>

3. Remove a Container

docker rm <container_name>
docker rm <container_id>

# remove all containers
docker rm -f $(docker ps -qa)