Try   HackMD

Docker 相關指令大全

tags: Docker CMD

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Docekr 常用指令

指令 名稱
docker images -a 顯示全部的 image(映像檔)
docker images -q 顯示全部的 image(映像檔) ID
docker container ls 顯示全部"運行中"的 container(容器)
docker container ls -a 顯示全部的 container(容器)
docker container kill <containerID> 終止特定 container(容器)
docker volume ls 顯示全部的 volume(數據)
docker volume ls -q 顯示全部的 volume(數據)名稱

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker image 指令建置

image 建置指令

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker build <-t tags> <-f {dockerName}> .

  • -t 可自定義 image 版本名稱:版本,以分隔號區分
  • -f 預設為 "PATH/Dockerfile",使用後可指定進行的檔案

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
其他相關細節指令可參考官網

C:\User\eclipse\setest> docker build -t anco:1.0.0 -f Dockerfile.txt .

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
注意指令中 需要一個小句點,才方可正常執行


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker image 移除

image 移除指令

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • docker images rm <imageID>
  • docker rmi <imageID>

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
若是想要一次清除 image 的檔案,則必須使用 bash CLI 介面指令處理

image 一次清除 : docker rmi $(docker images -a -q)

組合 docker images -q 特性僅取得 imageID 資訊
直接將 docker rmi 所需的 imageID 一口氣取出並直接移除


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker run 建置container | Port測試設定

當上述 image 已經建置完畢後,就可以啟動 container 設定

container 建置指令

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

docker run <--name containerName> <-p containerPort:imagePort> <imageID>

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
這裡要先說明關於 container Port 的設定問題,由上述圖片可以知道些事情

  • DOCKER_HOST (Linux VM) 建置 port 設定為 8089
  • Docker client (Window) 建置 port 設定為 9999

docker run 指令中 -port 設定有寫 <-p containerPort:imagePort>
其 containerPort 為 Docker client,imagePort 為 DOCKER_HOST

外部使用Port號為 Docker client(containerPort)
內部運作Port號為 DOCKER_HOST(imagePort)

所以在連線上應使用外部Port號 Docker client(containerPort) 的阜號

D:\source\anco_dessert>docker images -a
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
anco         1.0.0     e8d4ab832744   29 minutes ago   555MB
anco         1.0.1     e8d4ab832744   29 minutes ago   555MB

D:\source\anco_dessert> docker run --name ANCO -p 8085:8089 e8d4ab832744

...

Compiled successfully!

You can now view anco_dessert in the browser.

  Local:            http://localhost:8089/ANCO
  On Your Network:  http://172.17.0.2:8089/ANCO

Note that the development build is not optimized.
To create a production build, use npm run build.

webpack compiled successfully

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

以上述定若沒有清楚了解 container 與 host 之間的 Port號關聯
Port 的設定問題就會卡關,所以先了解下【外\內埠溝通連接問題】的處理才比較有效喔

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
關於docker文件上port的說明

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

docker 文件已說明 port 相關設定

  1. 127.0.0.1:80
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

    host machine(本身開docker的機器) 設定port為80連接埠
  2. 8080/tcp
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

    docker machine(docker內部建置linux機器) 設定port為8080連接埠

因此許多文章都會提及到連接埠說明 -p <host_port>:<docker_inner_port>


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker login 登入相關hub

login 相關使用可參考這裡

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker push 映像檔至 hub

如果未先使用 docker login 登入驗證,docker push 會被直接 denied

push 推送指令

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker push <dockerHubName/imageName:tags>

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

尚未登入成功,且 image檔名稱 不符合docker Hub推送原則

成功 push 至 dockerHub,需先於 dockerHub建置相關的 repository 位置才能push

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
docker start 啟動服務

意外在使用 cmd 執行 docker 指令發現有抱錯問題

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

於 Error Message 得知原來是 docker engine 服務尚未啟動

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

指令啟動 docker 服務就可以使用 docker 指令查看 image/container 了

cmd 啟動服務指令

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
start "" "<dockerAbsoluteLoaction> <Desktop.exe executeFile>"

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
連結