- install docker
apt-get install docker
also workswget -qO- https://get.docker.com/ | sh
run hello-world image
docker run hello-world
docker
tells os you are using docker program
run
a subcommand that creates & run a Docker container
hello-world
tells docker which image to load into the container
(1)find it locally
(2)if not available,find it on the hub
(3)load the image into the container and ran it
- find image whick you want on the hub
- list your local images
docker images
- build your own image
(1) write a Dockerfile, add lines to the file like this:
[1]FROM docker/whalesay:latest
whick image your image is based on.
[2]RUN apt-get -y update && apt-get install -y fortunes
add thefortunes
program to the image.
[3]CMD /usr/games/fortune -a | cowsay
tells thefortunes
program to pass a nifty quote to thecowsay
program.
(2) build an imange from your Dockerfile
docker bulid -t docker-whale .
(don’t forget . period)
this command takes theDockerfile
in the current dir,and bulids an imge called docker-whale on your local machine.
- list your new images
- tag,push ,and pull your image
(1) tag and push the image
docker images
list images on your local machine, and pick up theIMAGE ID
specified.
docker tag 5452ad69d37f zhangjianbo1989/docker-whale:latest
docker
use the docker program
tag
a subcommand that tags an image
5452ad69d37f
IMAGE ID
zhangjianbo1989
your account name from Docker Hub.
docker-whale
the image name
latest
version label
- push your image to your repository on the hub.
docker push zhangjianbo1989/docker-whale
- delete images from your local machine
docker rmi