对Docker常用命令的整理
生活随笔
收集整理的這篇文章主要介紹了
对Docker常用命令的整理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
?
查看docker版本信息、
#docker version #docker -v #docker info?
?
?
image鏡像操作命令
?
#docker search image_name //檢索image #docker pull image_name //下載鏡像 #docker images //列出本地鏡像 -a, --all=false Show all images; --no-trunc=false Don't truncate output; -q, --quiet=false Only show numeric IDs //刪除一個或者多個鏡像; -f, --force=false Force; --no-prune=false Do not delete untagged parents #docker rmi image_name //顯示一個鏡像的歷史; --no-trunc=false Don't truncate output; -q, --quiet=false Only show numeric IDs #docker history image_name容器操作
?
# 在容器中運行"echo"命令,輸出"hello word" $docker run image_name echo "hello word"# 交互式進入容器中 $docker run -i -t image_name /bin/bash# 后臺啟動鏡像 并更改鏡像名字 $docker run -d --name myImage centos# 在容器中安裝新的程序 $docker run image_name yum install -y app_name# 列出當前所有正在運行的container $docker ps # 列出所有的container $docker ps -a # 列出最近一次啟動的container $docker ps -l# 保存對容器的修改; -a, --author="" Author; -m, --message="" Commit message $docker commit ID new_image_name# 刪除所有容器 $docker rm `docker ps -a -q`# 刪除單個容器; -f, --force=false; -l, --link=false Remove the specified link and not the underlying container; -v, --volumes=false Remove the volumes associated to the container $docker rm Name/ID# 停止、啟動、殺死一個容器 $docker stop Name/ID $docker start Name/ID $docker kill Name/ID# 從一個容器中取日志; -f, --follow=false Follow log output; -t, --timestamps=false Show timestamps $docker logs Name/ID# 列出一個容器里面被改變的文件或者目錄,list列表會顯示出三種事件,A 增加的,D 刪除的,C 被改變的 $docker diff Name/ID# 顯示一個運行的容器里面的進程信息 $docker top Name/ID# 從容器里面拷貝文件/目錄到本地一個路徑 $docker cp Name:/container_path to_path $docker cp ID:/container_path to_path# 重啟一個正在運行的容器; -t, --time=10 Number of seconds to try to stop for before killing the container, Default=10 $docker restart Name/ID# 附加到一個運行的容器上面; --no-stdin=false Do not attach stdin; --sig-proxy=true Proxify all received signal to the process $docker attach ID#訪問另一個容器的命名空間 進入另一個容器 #安裝Linux工具包 $ yum install -y util-linux #獲取容器的Pid $docker inspect --format "{{.State.Pid}}" containerName #進入容器 $ nsenter --target Pid --mount --uts --ipc --net --pid#容器網絡配置 #隨機生成container到host端口映射 $docker run -d -P --name myNginx nginx #指定特定端口 將container 80到host91端口的映射 $docker run -d -p 91:80 --name myNginx imageName # -p ip: hostPort:containerPosrt $docker ps -l?
?
docker數據管理
?
?
# -v 綁定掛載一個數據卷 -h 給容器指定一個主機名 $docker run -it --name volume-test1 -h nginx -v /data/ imageName#或著手動設置映射 $docker run -it --name volume-test1 -h nginx -v /opt:/opt imageName#掛載另一容器, 另一容器volume-test2(即使容器已經停掉)來做volume-test1的專門的存儲 $docker run -it --name volume-test1 -h nginx --volumes-from volume-test2 imageName#顯示數據卷到host主機的映射關系 $docker inspect -f {{.Volumes}} volume-test1?
轉自:https://blog.csdn.net/lsgqjh/article/details/71178218
?
?
?
總結
以上是生活随笔為你收集整理的对Docker常用命令的整理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sql server安装记
- 下一篇: rz、sz 命令 安装(Xshell 安