Docker常用命令圖解:
Docker的命令是十分多的拂共,上面圖中的命令都是非常常用的命令凑懂,之后我們還會學(xué)習(xí)很多命令。說明如下:
容器生命周期管理
run
:Run a command in a new container,創(chuàng)建一個新的容器并運行一個命令芳肌。start
:Start a stopped containers,啟動容器肋层。restart
:Restart a running container亿笤,重啟運行的容器。stop
:Stop a running containers栋猖,停止容器净薛。kill
:Kill a running container,kill指定docker容器蒲拉。rm
:Remove one or more containers肃拜,移除一個或者多個容器。pause
:Pause all processes within a container雌团,暫停容器燃领。unpause
:Unpause a paused container,取消暫停容器锦援。create
:Create a new container柿菩,創(chuàng)建一個新的容器,同run雨涛,但不啟動容器枢舶。
容器操作
-
ps
:List containers,列出容器列表替久。 -
inspect
:Return low-level information on a container凉泄,查看容器詳細信息。 -
top
:Lookup the running processes of a container蚯根,查看容器中運行的進程信息后众。 -
events
:Get real time events from the server胀糜,從docker服務(wù)獲取容器實時事件。 -
exec
:Run a command in an existing container蒂誉,在己存在的容器上運行命令教藻。 -
attach
命令:Attach to a running container,當(dāng)前shell下attach連接指定運行容器右锨。 -
logs
:Fetch the logs of a container括堤,輸出當(dāng)前容器日志信息。 -
wait
:Block until a container stops绍移,then print its exit code悄窃,截取容器停止時的退出狀態(tài)值。 -
export
:Stream the contents of a container as a tar archive蹂窖,導(dǎo)出容器的內(nèi)容流作為一個tar歸檔文件[對應(yīng)import]轧抗。 -
port
:Lookup the public-facing port which is NAT-ed to PRIVATE_PORT,查看映射端口對應(yīng)的容器內(nèi)部源端口瞬测。
鏡像倉庫
-
login
:Register or Login to the docker registry server横媚,注冊或者登陸一個docker源服務(wù)器。 -
logout
:Log out from a Docker registry server月趟,從當(dāng)前Docker registry退出灯蝴。 -
pull
:Pull an image or a repository from the docker registry server,從docker鏡像源服務(wù)器拉取指定鏡像或者庫鏡像狮斗。 -
push
:Push an image or a repository to the docker registry server,推送指定鏡像或者庫鏡像至docker源服務(wù)器弧蝇。 -
search
:Search for an image on the Docker Hub碳褒,在docker hub中搜索鏡像。
容器rootfs命令
-
commit
:Create a new image from a container changes看疗,提交當(dāng)前容器為新的鏡像沙峻。 -
cp
:Copy files/folders from the containers filesystem to the host path,從容器中拷貝指定文件或者目錄到宿主機中两芳。 -
diff
:Inspect changes on a container's filesystem摔寨,查看docker容器變化。
本地鏡像管理
-
images
:List images怖辆,列出系統(tǒng)當(dāng)前鏡像是复。 -
rmi
:Remove one or more images,移除一個或多個鏡像[無容器使用該鏡像才可刪除竖螃,否則需刪除相關(guān)容器才可繼續(xù)或-f強制刪除]淑廊。 -
tag
:Tag an image into a repository,給源中鏡像打標(biāo)簽特咆。 -
build
命令:Build an image from a Dockerfile季惩,通過Dockerfile定制鏡像。 -
history
:Show the history of an image,展示一個鏡像形成歷史画拾。 -
load
:Load an image from a tar archive啥繁,從一個tar包中加載一個鏡像[對應(yīng)save]。 -
save
:Save an image to a tar archive青抛,保存一個鏡像為一個tar包[對應(yīng)load]旗闽。 -
import
:Create a new filesystem image from the contents of a tarball,從tar包中的內(nèi)容創(chuàng)建一個新的文件系統(tǒng)映像[對應(yīng)export]脂凶。
info|version
info
:Display system-wide information宪睹,顯示系統(tǒng)相關(guān)信息。version
:Show the docker version information蚕钦,查看docker版本號亭病。