This repository contains examples of Dockerfile used for creating docker container. Information of Docker could be found here.
To make use of docker, we need several steps for prerequisites:
-
First sign up on docker.com, then sign in to the dockerhub.
-
Download docker desktop.
Although there is a good tutorial on docker desktop download page, we still make a instruction here base on the tutorial and add several compensations.
Write your Dockerfile locally, you could save in on Github (the same as me) or anywhere you want. Examples of Dockerfile could be found in this repository.
Build your docker image locally by:
cd <your-Dockerfile-path> &&
docker build -t <TAG> .
Please don't loss the last dot in the command. I highly recommand that the <TAG>
should be of the form: <hub-user>/<repo-name>[:<tag>]
, or you may meet trouble when pushing the image to dockerhub. Default <tag>
name will be latest. If you create a docker with 'wrong' tag, change the tag by:
docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]
Push the docker image to dockerhub by:
docker push <hub-user>/<repo-name>[:<tag>]
You could run the docker image by:
docker run -it --rm <hub-user>/<repo-name>[:<tag>]
The image would automatically pull from dockerhub if the image is not found locally.
Show a list of local image by:
docker images
delete local image by:
docker rmi <image id>
or
docker rmi <hub-user>/<repo-name>[:<tag>]