2014年11月27日 星期四

Docker 常用指令

  1. docker search {keyword} # 搜尋雲端images
  2. docker pull {image} # 將雲端image拉回主機
  3. docker build -t {tag} {path} # 使用Dockerfile建立image
  4. docker run {options} {image} {command} # 從image執行指令(建立container)
  5. docker run -i -t {image} /bin/bash # 進入container shell,(ctrl+p) + (ctrl+q)可丟背景離開shell
  6. docker inspect --format='{{.NetworkSettings.IPAddress}}' {container} # 查看container IP
  7. docker images # 查看local所有的images
  8. docker ps -a # 查看container包含已結束的
  9. docker rm {container} # 移除已結束的container
  10. docker rm $(docker ps -a -q) # 移除所有container
  11. docker rmi {image} # 移除image
  12. docker commit {comtainer} {image} # 將container異動過的內容寫入image
  13. docker start {container} # 重新啟動已結束的container
  14. docker attach {container} # 重新接入正在執行container
  15. docker save {image} > {tarball} # 備份image
  16. docker load < {tarball} # 還原image