歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> tag上、push上和pull 取Docker 映像

tag上、push上和pull 取Docker 映像

日期:2017/2/28 13:44:15   编辑:Linux教程

tag上、push上和pull 取Docker 映像,在此之前需要擁有一個docker Hub賬戶,注冊地址:https://hub.docker.com/。

Tag、Push Docker映像

  1. 使用docker images 獲取當前擁有的映像列表,其中可獲取映像ID。
    $ docker images
     REPOSITORY           TAG          IMAGE ID            CREATED             SIZE
     docker-whale         latest       7d9495d03763        38 minutes ago      273.7 MB
     <none>               <none>       5dac217f722c        45 minutes ago      273.7 MB
     docker/whalesay      latest       fb434121fc77        4 hours ago         247 MB
     hello-world          latest       91c95931e552        5 weeks ago         910 B
  2. 查找特定映像的ID,如 docker-whale:這個例子中的ID是:7d9495d03763 。注意:'REPOSITORY' 顯示的是docker-whale的倉庫名稱,而不是命令空間,你需要將命令空間和你的Docker Hub賬戶聯系起來,你的命令空間要和你的賬戶的賬  戶名稱相同,因此將其重命名'YOUR_DOCKERHUB_NAME/docker-whale' 。
     $ docker tag 7d9495d03763 maryatdocker/docker-whale:latest
    maryatdocker為自己的DockerHub賬戶。
  3. docker login命令用於在命令行中登錄Docker Hub賬戶:
     $ docker login
     Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
     Username:
     Password:
     Login Succeeded
  4. push 命令用於將映像推送到倉庫當中:
     $ docker push maryatdocker/docker-whale
         The push refers to a repository [maryatdocker/docker-whale] (len: 1)
         7d9495d03763: Image already exists
         c81071adeeb5: Image successfully pushed
         eb06e47a01d2: Image successfully pushed
         fb434121fc77: Image successfully pushed
         5d5bd9951e26: Image successfully pushed
         99da72cfe067: Image successfully pushed
         1722f41ddcb5: Image successfully pushed
         5b74edbcaa5b: Image successfully pushed
         676c4a1897e6: Image successfully pushed
         07f8e8c5e660: Image successfully pushed
         37bea4ee0c81: Image successfully pushed
         a82efea989f9: Image successfully pushed
         e9e06b06e14c: Image successfully pushed
         Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011

Pull 獲取最新創建的映像

  1. 使用docker rmi -f 強力移除本地已經存在的映像:
     $ docker rmi -f 7d9495d03763
     $ docker rmi -f docker-whale

    PS:使用ID或者名稱均可。

  2. 使用docker run 命令從倉庫中拉取並載入映像:
    docker run yourusername/docker-whale

    PS:此處應該包含對應的Docker Hub賬戶名。

Copyright © Linux教程網 All Rights Reserved