docker常用命令

  • 使用Dockerfile編譯生成鏡像
docker build -t 鏡像標(biāo)簽名 .(Dockerfile存放的路徑)
  • 拉取遠(yuǎn)程鏡像
docker pull 遠(yuǎn)端鏡像地址
  • docker save 打包(既可以對(duì)image打包也可以對(duì)container打包)
# 幫助
docker save --help 

Usage:  docker save [OPTIONS] IMAGE [IMAGE...]

Save one or more images to a tar archive (streamed to STDOUT by default)

Options:
  -o, --output string   Write to a file, instead of STDOUT
# 使用
docker save -o 輸出的tar包名 image名(container名) image名(container名) ...
  • 將tar載入鏡像 docker load
# 幫助
docker load --help 

Usage:  docker load [OPTIONS]

Load an image from a tar archive or STDIN

Options:
  -i, --input string   Read from tar archive file, instead of STDIN
  -q, --quiet          Suppress the load output
# 使用
docker load -i tar包名
  • docker export 導(dǎo)出container
# 幫助
docker export --help

Usage:  docker export [OPTIONS] CONTAINER

Export a container‘s filesystem as a tar archive

Options:
  -o, --output string   Write to a file, instead of STDOUT
# 使用
docker export -o 導(dǎo)出的tar包名 container名
  • docker import導(dǎo)出的container
# 幫助
docker import --help 

Usage:  docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]

Import the contents from a tarball to create a filesystem image

Options:
  -c, --change list      Apply Dockerfile instruction to the created image
  -m, --message string   Set commit message for imported image
  • docker 刪除本地image
# 幫助
docker rmi --help

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Options:
  -f, --force      Force removal of the image
      --no-prune   Do not delete untagged parents
# 幫助
docker rm --help

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers

Options:
  -f, --force     Force the removal of a running container (uses SIGKILL)
  -l, --link      Remove the specified link
  -v, --volumes   Remove the volumes associated with the container
  • docker 移除container
# 幫助
docker rm --help 

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers

Options:
  -f, --force     Force the removal of a running container (uses SIGKILL)
  -l, --link      Remove the specified link
  -v, --volumes   Remove the volumes associated with the container
  • docker kill container
# 幫助
docker kill --help 

Usage:  docker kill [OPTIONS] CONTAINER [CONTAINER...]

Kill one or more running containers

Options:
  -s, --signal string   Signal to send to the container (default "KILL")
  • docker 在container中執(zhí)行命令
# 幫助
docker exec --help 

Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container

Options:
  -d, --detach               Detached mode: run command in the background
      --detach-keys string   Override the key sequence for detaching a container
  -e, --env list             Set environment variables
  -i, --interactive          Keep STDIN open even if not attached
      --privileged           Give extended privileges to the command
  -t, --tty                  Allocate a pseudo-TTY
  -u, --user string          Username or UID (format: <name|uid>[:<group|gid>])
  -w, --workdir string       Working directory inside the container
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • docker常用命令詳解 - CSDN博客 本文只記錄docker命令在大部分情境下的使用,如果想了解每一個(gè)選項(xiàng)的...
    Meathill大魔王閱讀 885評(píng)論 1 2
  • 本文只記錄docker命令在大部分情境下的使用,如果想了解每一個(gè)選項(xiàng)的細(xì)節(jié),請(qǐng)參考官方文檔,這里只作為自己以后的備...
    Joncc閱讀 319評(píng)論 0 0
  • Docker基礎(chǔ) 這篇基礎(chǔ)文章是方便用戶在使用cSphere平臺(tái)之前,了解docker基礎(chǔ)知識(shí)。 針對(duì)已經(jīng)有一定的...
    4ea0af17fd67閱讀 488評(píng)論 0 0
  • 容器相關(guān)操作 docker create # 創(chuàng)建一個(gè)容器但是不啟動(dòng)它 docker run # 創(chuàng)建并啟動(dòng)一個(gè)容...
    藍(lán)色的咖啡閱讀 864評(píng)論 0 3
  • 綺蔓有羅(四) 綺羅睜眼的時(shí)候,發(fā)現(xiàn)自己躺在自己的房間里,林染正守在她身側(cè),看見她醒驚喜的喚著,“青衣,青衣,你家...
    瘋草葉子閱讀 454評(píng)論 0 2

友情鏈接更多精彩內(nèi)容