首頁 > 軟體

tag上、push上和pull 取Docker 映像

2020-06-16 17:23:10

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賬戶名。

更多Docker相關教學見以下內容

Docker安裝應用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm

Ubuntu 14.04安裝Docker  http://www.linuxidc.com/linux/2014-08/105656.htm

Ubuntu使用VNC執行基於Docker的桌面系統  http://www.linuxidc.com/Linux/2015-08/121170.htm

阿里雲CentOS 6.5 模板上安裝 Docker http://www.linuxidc.com/Linux/2014-11/109107.htm

Ubuntu 15.04下安裝Docker  http://www.linuxidc.com/Linux/2015-07/120444.htm

在Ubuntu Trusty 14.04 (LTS) (64-bit)安裝Docker http://www.linuxidc.com/Linux/2014-10/108184.htm

在 Ubuntu 15.04 上如何安裝Docker及基本用法 http://www.linuxidc.com/Linux/2015-09/122885.htm

Ubuntu 16.04上Docker使用手記 http://www.linuxidc.com/Linux/2016-12/138490.htm


IT145.com E-mail:sddin#qq.com