1. 鏡像的獲取方式
pull from registry
(online ) 從registry拉取
build from Dockerfile
(online) 從dockerfile構建
構建的過程需要上網,拉取基礎的images也可是自架的docker hub 伺服器
load from file
(offline)文件導入(離線)
透過鏡像的save
指令導出一個鏡像檔,可以通過usb等硬體裝置儲存攜帶,再插到另一台機器讀取,接著再利用load
指令導入到docker裡。
2. 鏡像的registry介紹 registry網站
3. 鏡像的獲取和查看 1 2 3 4 5 6 7 8 9 # 拉取鏡像寫法 docker image pull nginx # 較舊寫法 不需要寫image docker pull nginx # 查看本地的image 清單 以下兩個語法都可以 docker image ls docker images
在nginx 後面如果沒有加上tag名稱時,會預設抓latest
的tag進行拉取。
舉例來說,我們可以先從docker hub 找到你要的版本,以1.20.2為例:
接著我們在輸入指令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 root@kite-virtual-machine:/home/kite/Desktop# docker pull nginx:1.20.2 1.20.2: Pulling from library/nginx 5eb5b503b376: Pull complete cdfeb356c029: Pull complete d86da7454448: Pull complete 7976249980ef: Pull complete 8f66aa6726b2: Pull complete c004cabebe76: Pull complete Digest: sha256:02923d65cde08a49380ab3f3dd2f8f90aa51fa2bd358bd85f89345848f6e6623 Status: Downloaded newer image for nginx:1.20.2 docker.io/library/nginx:1.20.2 root@kite-virtual-machine:/home/kite/Desktop# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx 1.20.2 d6c9558ba445 2 weeks ago 141MB
下docker images
就會看到拉取了1.20.2 的鏡像。
我們用另一個示例來玩看看,首先,先到quay
網站來查詢nginx,我們copy 指令docker pull quay.io/bitnami/nginx
。針對這個指令的說明一下:
第一個quay.io
指的是registry 的網址
第二個bitnami
是發行的組(group)或是擁有者(owner),比如是一個用戶的id
第三個nginx
是鏡像名稱
執行完結果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 root@kite-virtual-machine:/home/kite/Desktop# docker pull quay.io/bitnami/nginx Using default tag: latest latest: Pulling from bitnami/nginx a2b89359fa38: Pull complete eb3d3b400740: Pull complete 46e8977b34c6: Pull complete ba19e4f3bb28: Pull complete b32f6ece772b: Pull complete 93564c931307: Pull complete e5b3ce1bf203: Pull complete 724a66987928: Pull complete e556e9ce9174: Pull complete 61c0aa354bde: Pull complete c14227a7baae: Pull complete 055df77435e3: Pull complete Digest: sha256:f9b149213fa98cee7750ede87bbec1109971c7a2cfa556c89b7d2cbf3697b213 Status: Downloaded newer image for quay.io/bitnami/nginx:latest quay.io/bitnami/nginx:latest root@kite-virtual-machine:/home/kite/Desktop# docker images REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/bitnami/nginx latest fef44885d7d3 15 hours ago 89.4MB nginx 1.20.2 d6c9558ba445 2 weeks ago 141MB
我們透過docker image ls
看到的訊息是比較簡易的,如果要看完整詳細的docker訊息可以透過docker image inspect [names] or [container id]
這個指定來看詳細內容,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 docker image inspect d6c [ { #這項是鏡像完整的id "Id": "sha256:d6c9558ba4456741fc4ee304e1a75a561e1c8d92f5107a715b6224bb7844f507", "RepoTags": [ "nginx:1.20.2" ], ... #這項是鏡像的架構,比方說如果你是MAC 的M1晶片,可能就必須選用ARM架構,就選擇AMD64 "Architecture": "amd64", #這項是鏡像的作業系統 "Os": "linux", ... "RootFS": { "Type": "layers", #之前有講到docker是有分層的概念,也就是對應到這個,後續再詳細說明 "Layers": [ "sha256:7d0ebbe3f5d26c1b5ec4d5dbb6fe3205d7061f9735080b0162d550530328abd6", "sha256:f7d96e665ae1a81d81e18e2503b2341bec8491606ffa6e2b48480a8e741dfab7", "sha256:a64a30dea1c4b926a45abed0728327d079d2c5fa4a7b7e6aa2d06136783a27a2", "sha256:dc78c3d0e91713e0b45a209df1509fb96d4f6a4f3099f4dfbc9e9ae71b143e43", "sha256:8fa2ccbce0c21c1a0140ce0f2db6b92f92c16f9ff00e4c8a1daaea548799b698", "sha256:b1073b41766d15d7835ea97e5eaf7f2f8a06b7fd1549ecbc2c9697813ede853a" ] }, ... } ]
簡單說明幾個部分:
ID
Architecture
鏡像的架構,比方說如果你是MAC 的M1晶片,可能就必須選用ARM架構,就選擇AMD64
Os
Layers
之前有講到docker是有分層的概念,也就是對應到這個,後續再詳細說明
鏡像檔的刪除注意事項
透過以下的例子,我們發現其實要移除鏡像檔必須這個鏡像在沒有被container引用,並且就算已經停止的container 也必須移除,才有辦法完成鏡像檔的刪除動作。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 # 1. 列出目前的鏡像清單 root@kite-virtual-machine:/home/kite/Desktop# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest c316d5a335a5 2 weeks ago 142MB # 2. 啟動nginx root@kite-virtual-machine:/home/kite/Desktop# docker container run -d nginx 7dc905570d71599e9712f2dd978f25ef987d351f15b85231e79a8f5099bfda2b # 3. 移除鏡像檔 發生錯誤 root@kite-virtual-machine:/home/kite/Desktop# docker image rm c3 Error response from daemon: conflict: unable to delete c316d5a335a5 (cannot be forced) - image is being used by running container 7dc905570d71 # 4. 停用container root@kite-virtual-machine:/home/kite/Desktop# docker container stop 7dc9 7dc9 # 5. 再次移除鏡像檔 發生錯誤 root@kite-virtual-machine:/home/kite/Desktop# docker image rm c3 Error response from daemon: conflict: unable to delete c316d5a335a5 (must be forced) - image is being used by stopped container 7dc905570d71 # 6. 移除container root@kite-virtual-machine:/home/kite/Desktop# docker container rm 7dc9 7dc9 # 7. 移除鏡像檔 完成 root@kite-virtual-machine:/home/kite/Desktop# docker image rm c3 Untagged: nginx:latest Untagged: nginx@sha256:2834dc507516af02784808c5f48b7cbe38b8ed5d0f4837f16e78d00deb7e7767 Deleted: sha256:c316d5a335a5cf324b0dc83b3da82d7608724769f6454f6d9a621f3ec2534a5a Deleted: sha256:67e568696593c33b4a15c9d81dc6f67499b8d973b88eb49b53d47bf4dbf4d187 Deleted: sha256:0f8d4e3d979c540644f248b4206cf540978166b095223bdc950628dca2e8f3f1 Deleted: sha256:5d75bfe8a7422476a495b27c8a1598d1206137631d350b8bdee13bc88f365282 Deleted: sha256:8284a9e28c625b2826efdd6160ea1ff7f710881a4a2afe1ef58a5eb51d3f919e Deleted: sha256:89a1db9e1079b7574c1a707bc8c1fe04ff723bc71d4bca8bc48653e9a32186d2 Deleted: sha256:7d0ebbe3f5d26c1b5ec4d5dbb6fe3205d7061f9735080b0162d550530328abd6
3.1. image output 和image load 匯出指令,其中 -o
是output
的縮寫
1 docker image save quay.io/bitnami/nginx -o nginx.image
匯入指令,其中 -i
是 input
的縮寫
1 docker image load -i ./nginx.image
4. 鏡像的導出和導入(offline) 小實驗,動手下指令玩玩看,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 # 匯出鏡像檔 root@kite-virtual-machine:/home/kite/Desktop# docker image save quay.io/bitnami/nginx -o nginx.image # 查看當前路徑是否有剛剛匯出的鏡像 root@kite-virtual-machine:/home/kite/Desktop# ll total 91340 drwxr-xr-x 2 kite kite 4096 二 16 15:27 ./ drwxr-xr-x 23 kite kite 4096 二 11 09:44 ../ -rw------- 1 root root 93520384 二 16 15:27 nginx.image # 先刪除鏡像,為了後面測試load指定 root@kite-virtual-machine:/home/kite/Desktop# docker image rm quay.io/bitnami/nginx Untagged: quay.io/bitnami/nginx:latest Untagged: quay.io/bitnami/nginx@sha256:f9b149213fa98cee7750ede87bbec1109971c7a2cfa556c89b7d2cbf3697b213 Deleted: sha256:fef44885d7d30571af3156ceaf232702d5b8f6771cda3ed724f8cc272e9c9829 Deleted: sha256:a189c52fed386394dbb7ffb51c5c462ad2ba77c26c01d5c01e72b15e40db29c0 Deleted: sha256:2f1c8bd99f51d77b4323230921f2ca86706e353cf2d775cf0b002e0e479f79e6 Deleted: sha256:5c2ae43f5fa2f4dacbf202f3a363c3320eba7f78806e059bb0f893b925c46f53 Deleted: sha256:0a946840cdb0258bf1b59a31680050dd60085769b79f3b44d7aa17ec069424f6 Deleted: sha256:c5693486bf8d9e4a52a4925ff9f0c37861c3bb7646484f424b9a6b04b1b0eaf3 Deleted: sha256:9efb4fc4677072eb2a7d83a8cf75aff78e35599aed05d4177b02bc557f878832 Deleted: sha256:342797d9b97f8ca828cd8c7fc8081497627a0c249f1a808f7df8f66de8c48969 Deleted: sha256:2b660bfea22ebf12cf21e46a323d73c68ef0094fc327d8ff1f7b9c5e6c8540e5 Deleted: sha256:00251eb08c244921e37ee3e3f0e7b1f03d1f0d465f88c268372e6b1bbd3a29ad Deleted: sha256:305bbe3d88ac18f896068c246f07787570634b63bfbd47a2b9d65329b7d25558 Deleted: sha256:a0fc422098a3de3df394bfcb3e085abd4fe28f58ef8b1d8f5a273529fbf5e65d Deleted: sha256:ae58f1561944087b459d2688dff7eda143f4d7512f05bf2b52f134fdfd2b8cd4 # 加載剛output的鏡像 root@kite-virtual-machine:/home/kite/Desktop# docker image load -i ./nginx.image ae58f1561944: Loading layer [==================================================>] 70.8MB/70.8MB 2f6f61f3bbc9: Loading layer [==================================================>] 81.92kB/81.92kB 3bfda742b4b4: Loading layer [==================================================>] 15.14MB/15.14MB 6ed2fe854cdb: Loading layer [==================================================>] 2.634MB/2.634MB dddc1a8d1029: Loading layer [==================================================>] 2.374MB/2.374MB 269fbc668e52: Loading layer [==================================================>] 2.307MB/2.307MB c12665b38039: Loading layer [==================================================>] 5.632kB/5.632kB 52f2403acee0: Loading layer [==================================================>] 2.048kB/2.048kB 260212c608b3: Loading layer [==================================================>] 3.584kB/3.584kB 0eca2613dc76: Loading layer [==================================================>] 3.584kB/3.584kB 29a9d19d38b2: Loading layer [==================================================>] 60.42kB/60.42kB da0a9db5694c: Loading layer [==================================================>] 60.93kB/60.93kB Loaded image: quay.io/bitnami/nginx:latest # 查看目前鏡像清單,成功的匯入囉 root@kite-virtual-machine:/home/kite/Desktop# docker images REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/bitnami/nginx latest fef44885d7d3 16 hours ago 89.4MB
5. Dockerfile介紹 官網的dockerfile 說明
Docker can build images automatically by reading the instructions from a Dockerfile
. A Dockerfile is a text
document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.
Dockerfile 是用於構建於docker鏡像的文件
Dockerfile 裡面包含了構建鏡像所需的”指令”
Dockerfile有其特定的語法規則
6. 鏡像構建準備 6.1. 舉例:執行一個python程式 假如我們要在一台ubuntu21.04上運行下面這個hello.py的python腳本
6.1.1. python腳本 1 print ("hello docker,I'm kite" )
所以我們這個環境需要兩樣東西ubuntu21.04
、python
,並且執行python3 hello.py
腳本。
6.1.2. 具體Dockerfile結構 1 2 3 4 5 FROM ubuntu:21.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 python3-pip python3.9-dev ADD hello.py / CMD ["python3" , "/hello.py" ]
FROM
:抓一個我們需要的ubuntu版本
RUN
:下指令安裝python
ADD
:加入hello.py 腳本至鏡像內的根目錄
CMD
:以python3 方式執行 路徑/hello.py
程式
6.1.3. 執行流程
建立目錄
1 mkdir genDockerImagesFolder
進入目錄
1 cd genDockerImagesFolder/
建立hello.py檔
1 echo "print('hello,docker')" > hello.py
建立Dockerfile檔
1 2 3 4 5 6 7 cat <<EOT >> Dockerfile > FROM ubuntu:21.04 > RUN apt-get update && \ > DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 python3-pip python3.9-dev > ADD hello.py / > CMD ["python3" , "/hello.py" ] > EOT
說明:在build image檔時,必須在資料夾內有Dockerfile
檔案,後續下build指令才會成功
確認資料夾檔案
build 鏡像檔
1 2 3 4 5 6 7 8 # 指令格式 # docker image build -t [imagename] [path] # 預設是lastest docker image build -t hello . # 給tag docker image build -t hello:1.0 .
說明:
-t
:指的是tag
imagename
:hello
path
:.
(當前路徑)
具體語法說明可以參考Dockerfile reference ,以下是練習建image的指令過程:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 # 建立目錄 root@kite-virtual-machine:/home/kite/Desktop# mkdir genDockerImagesFolder # 進入目錄 root@kite-virtual-machine:/home/kite/Desktop# cd genDockerImagesFolder/ # 建立hello.py檔 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# echo "print('hello,docker')" > hello.py # 建立Dockerfile檔 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# cat <<EOT >> Dockerfile > FROM ubuntu:21.04 > RUN apt-get update && \ > DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 python3-pip python3.9-dev > ADD hello.py / > CMD ["python3" , "/hello.py" ] > EOT # 確認資料夾檔案 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# ll total 16 drwxr-xr-x 2 root root 4096 二 17 11:58 ./ drwxr-xr-x 3 kite kite 4096 二 17 11:50 ../ -rw-r--r-- 1 root root 198 二 17 11:58 Dockerfile -rw-r--r-- 1 root root 22 二 17 11:51 hello.py # build 鏡像檔 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker image build -t hello . Step 1/4 : FROM ubuntu:21.04 ---> 7cc39f89fa58 Step 2/4 : RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 ... ... ... Step 3/4 : ADD hello.py / ---> 864392501c61 Step 4/4 : CMD ["python3", "/hello.py"] ---> Running in 6ddb6041461e Removing intermediate container 6ddb6041461e ---> 698fa0b38d79 Successfully built 698fa0b38d79 Successfully tagged hello:latest
build 的過程需要一些時間,等到我們看到suceccfully之後,代表已經完成了,接著檢查看看下指令docker images
1 2 3 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello latest 698fa0b38d79 15 minutes ago 206MB
hello 鏡像檔就出現在清單中囉,如果要導出鏡像記得再看前面的部分進行操作即可。
試著用it
交互的相方運行hello 容器如下:`
1 2 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker run -it hello hello,docker
7. 鏡像分享
先註冊一個Dockerhub
帳號
因為先前建立的鏡像沒有加上用戶名,所以可以通過以下兩個方式做準備
1 2 3 4 5 # 重新build一個並加入id docker image build -t kitefree/hello . # 針對既有的hello鏡像 複製並新增一個 docker image tag hello kitefree/hello:1.0
執行登入指令
登出為
會要求輸入帳號密碼,登入完成後進行布署
1 docker image push kitefree/hello:1.0
過程如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# 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: kitefree Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker image push kitefree/hello:1.0 The push refers to repository [docker.io/kitefree/hello] 3948f6982f11: Pushed 24ac8aef82f9: Pushed dca6a631e9bb: Mounted from library/ubuntu 1.0: digest: sha256:8f7be9cd060a67593a089a4111b8c5a3127e324c49aeed0843f578a100eba2b6 size: 948
接著登入後台查看一下結果
我們試著pull鏡像檔下來,我們先把本地端的鏡像檔刪除。
拉取鏡像語法
1 docker pull kitefree/hello:1.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # 刪除本地鏡像 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker image rm kitefree/hello:1.0 Untagged: kitefree/hello:1.0 Untagged: kitefree/hello@sha256:8f7be9cd060a67593a089a4111b8c5a3127e324c49aeed0843f578a100eba2b6 # 拉取鏡像 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker pull kitefree/hello:1.0 1.0: Pulling from kitefree/hello Digest: sha256:8f7be9cd060a67593a089a4111b8c5a3127e324c49aeed0843f578a100eba2b6 Status: Downloaded newer image for kitefree/hello:1.0 docker.io/kitefree/hello:1.0 # 檢查本地鏡像 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker images REPOSITORY TAG IMAGE ID CREATED SIZE kitefree/hello 1.0 698fa0b38d79 17 hours ago 206MB
8. 通過commit創建鏡像 我們目標是進入容器內部直接修改文件,停用再啟用容器,我們會發現改的東西已經成功寫入到容器內部了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 # 啟動一個nginx容器 root@kite-virtual-machine:/home/kite/Desktop# docker run -d -p 8000:80 --name nginx01 nginx 5544cc14e2af3ed16dc875a9bb9b3594066bc695f94272ce6f6794f4a66714a7 # 進入容器內部 root@kite-virtual-machine:/home/kite/Desktop# docker exec -it 554 sh # 修改首頁文字 echo "hello,docker" > /usr/share/nginx/html/index.html # 離開容器 exit # 停止容器 root@kite-virtual-machine:/home/kite/Desktop# docker container stop 554 554 # 啟用容器 root@kite-virtual-machine:/home/kite/Desktop# docker container start 554 554 # 查看容器異動的差異 root@kite-virtual-machine:/home/kite/Desktop# docker diff nginx01 C /var C /var/cache C /var/cache/nginx A /var/cache/nginx/fastcgi_temp A /var/cache/nginx/proxy_temp A /var/cache/nginx/scgi_temp A /var/cache/nginx/uwsgi_temp A /var/cache/nginx/client_temp C /usr C /usr/share C /usr/share/nginx C /usr/share/nginx/html C /usr/share/nginx/html/index.html C /run A /run/nginx.pid C /etc C /etc/nginx C /etc/nginx/conf.d C /etc/nginx/conf.d/default.conf
以瀏覽器去查看webserver 的確在啟動後是有修改還是有效的。
接著,我們來玩玩看用commit 指令創建一個鏡像
1 2 3 4 5 6 7 8 9 10 11 12 13 # 指定容器id 554 進行commit 並創建名為 kitefree/nginx 儲存庫 root@kite-virtual-machine:/home/kite/Desktop# docker commit 554 kitefree/nginx sha256:799b17a2576601b6db1431f9d5b901843470ad9180e9c99aa86c0d1a7aef4569 # 查看目前鏡像清單 root@kite-virtual-machine:/home/kite/Desktop# docker images REPOSITORY TAG IMAGE ID CREATED SIZE kitefree/nginx latest 799b17a25766 8 seconds ago 142MB nginx latest c316d5a335a5 3 weeks ago 142MB # 啟動容器 並給port 8001 root@kite-virtual-machine:/home/kite/Desktop# docker run -d -p 8001:80 --name kite_nginx kitefree/nginx 4416889d90c4dc29292cbbe3cc35184d240d491975a2367c800651329ddc5627
在以瀏覽器方式查看,我們會看到一樣為hello,docker
的網頁顯示訊息。
9. 聊聊scratch鏡像 是一個empty image ,無法通過docker pull 拉取鏡像,但是可以FROM scratch
構建鏡像。在工作上比較少用到scratch鏡像,所以簡單的玩一下
以下為測試的執行過程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 # 建立一個c語言的程式碼 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# cat <<EOT >>hello.c > > > int main() > { > printf ("hello docker\n" ); > } > EOT # 執行編譯產出hello檔 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# gcc --static -o hello hello.c root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# ls Dockerfile hello hello.c hello.py # 測試執行是否正常輸入字串 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# ./hello hello docker # 建立dockerfile檔案 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# cat <<EOT >>Dockerfile > FROM scratch > ADD hello / > CMD ["/hello" ] > EOT # 構建鏡像檔 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker build -t kitefree/scratch . Sending build context to Docker daemon 876.5kB Step 1/3 : FROM scratch ---> Step 2/3 : ADD hello / ---> f95110c6fba2 Step 3/3 : CMD ["/hello"] ---> Running in 3a60c6a60ed1 Removing intermediate container 3a60c6a60ed1 ---> f39f26ad08a6 Successfully built f39f26ad08a6 Successfully tagged kitefree/scratch:latest root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker images REPOSITORY TAG IMAGE ID CREATED SIZE kitefree/scratch latest f39f26ad08a6 7 seconds ago 872kB # 啟動容器執行 ,這邊多加了rm 參數是指執行完後會自動刪除容器 root@kite-virtual-machine:/home/kite/Desktop/genDockerImagesFolder# docker run -it --rm kitefree/scratch hello docker
10. 拉取次數的計算 如果是以匿名方式拉取,會以IP方式計算
如果是以帳號登入方式拉取,那計算方式就會計算在帳號上面。當在公司同一個網段時,如果都用帳號的部分去進行拉取,基本上比較不用擔心有次數上的問題。
拉取次數目前的使用狀況可以透過curl request 指令進行查詢