docker basic guide

来源:互联网 发布:mac chown命令详解 编辑:程序博客网 时间:2024/06/12 23:14


  1. install docker apt-get install docker
    also works wget -qO- https://get.docker.com/ | sh
  2. 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 the fortunes program to the image.
    [3]CMD /usr/games/fortune -a | cowsay
    tells the fortunes program to pass a nifty quote to the cowsay program.
    (2) build an imange from your Dockerfile
    • docker bulid -t docker-whale . (don’t forget . period)
      this command takes the Dockerfile 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 the IMAGE 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
  • 0 0