docker run - Run a command in a new container
啟動一個新的容器,一般在docker pull之后首次運行此image
-i 保持stdout打開
-t 打開一個tty
-d 后台運行, 不加-d時運行完可能會自動結束
Ctrl+P+Q 退出tty並保持后台運行
docker start - Start one or more stopped containers
新的容器退出后(比如關機重啟了),如果仍然使用docker run xxxx的話,以前的操作內容不會保存。此時可以使用docker start啟動歷史的容器
上圖中使用了兩次run mongo, 因此有兩個container id, 使用docker start仍能看到歷史數據.
docker restart 重啟一個運行中的容器
docker exec - Run a command in a running container
容器啟動后,使用docker ps獲得運行中的容器id, 然后使用docker exec進入此運行中的容器。如果有多個參數,不要加“”
后台運行使用-d, 不是使用&
docker top 顯示容器內運行中的進程
docker stats 查看容器內存使用量, 相當於linux shell 中的TOP /iostat
docker commit -Create a new image from a container's changes
在容器的基礎上創建新的image, 可以指定自己的imageName:tag。
docker build
從DockerFile創建image, DockerFile中可以使用apt|yum安裝特定的軟件
docker push -Push an image or a repository to a registry
將自己的image推到倉庫,方便分享
docker network ls/ inspect 查看橋接后的內網ip
卷掛載 -保存歷史數據的另一種方法 https://www.cnblogs.com/lighten/p/6900556.html
容器編排,批量啟動?