OS: CentOS 7
Install Docker:

# yum install docker-ce-cli docker-ce

Start Docker:

# systemctl start docker

Help:

# docker –help

You can tack on a –help on the end of any command to get help of that specific option:

# docker pull –help

Pull in an image from hub.docker.com:

# docker pull ubuntu

To list your installed images and obtain the IMAGE ID:

# docker images

To run an image:

# docker run -it -d ubuntu

To view running images:

# docker ps

To stop a running container:

# docker stop ‘CONTAINTER ID

To execute a command in a container (In this case, bash in the ubuntu image.):

# docker exec -it ‘CONTAINTER ID‘ bash

To view all container, including those that are not running:

# docker ps -a

To remove a container:

# docker rm ‘CONTAINTER ID

To remove an image:
# docker rmi ‘IMAGE ID

To stop and remove a running container:

# docker rm -f ‘CONTAINTER ID

To save changes to a container:

# docker commit ‘CONTAINTER ID‘ ‘NEW IMAGE NAME

To remove all running containers:

# docker rm -f $(docker ps -a -q)

NOTE: INSTANCE ID can refer an image or container. The next two command will return the information in json format.
To view a container’s history:

# docker history ‘INSTANCE ID

To view information about a container:

# docker inspect ‘INSTANCE ID

If you want to upload your container to hub.docker.com the container must have a name in the following format:

# docker commit ‘CONTAINTER ID‘ ‘dockerhubuserid’/’newimagename’

To run a container and map a host port to the container port:

# docker run -it -d -p 82:80 jgz/apache2

Then, in this case, I would access my container web server from my LAN by accessing my docker host name and the port 82. So, if my hostname is jims.domain.local, the I would browse to http://jims.domain.local:82.

A Dockerfile is how you can create a container and run some commands when you start it up:
Building a Dockerfile (YAML file):

# mkdir /usr/local/docker
# cd /usr/local/docker/
# vi Dockerfile

FROM ubuntu
RUN apt-get update
RUN apt-get -y install apache2
ADD . /var/www/html
ENTRYPOINT apachectl -D FOREGROUND
ENV name jgz

This will build the container and execute the RUN commands and ENTRYPOINT command:

# docker build . -t new_dockerfile