Here is what I learned from the official Docker documentation: Get Started.
docker version
docker info
docker ps # list running containers
docker run hello-world
docker ps -a # list all containers
docker run docker/cowsay cowsay boo
docker ps -a
docker images
mkdir mydockerbuild
cd mydockerbuild
vi Dockerfile
FROM docker/whalesay:latest
# this is important if you are behind a proxy
RUN echo 'Acquire::http::Proxy "http://proxy-addr:proxy-port";' > /etc/apt/apt.conf.d/proxy
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay
docker build -t docker-whale .
docker images
docker run docker-whale
docker images # get the id of the image that you want to tag
docker tag <image-id> feici02/docker-whale:latest
docker images
Note: feici02 is my Docker Hub ID.
docker login
# push the image to Docker Hub
docker push feici02/docker-whale
docker images
docker rmi <images-id> # delete above image
# pull the image from Docker Hub
docker run feici02/docker-whale # it will be downloaded automatically
# delete all containers
docker rm $(docker ps -aq)