docker命令

1.建立鏡像
docker build -t friendlyname . # Create image using this directory's Dockerfile
2.運行friendlyhello,docker內部的端口映射到宿主機的4000,我們訪問應用用4000
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
3.后臺的方式運行
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
4.查看運行的容器
docker ps # See a list of all running containers
5.停止運行的容器,id通過 docker ps查看
docker stop <hash> # Gracefully stop the specified container
6.查看所有的容器不管是否運行的
docker ps -a # See a list of all containers, even the ones not running

  1. 強制殺死指定的容器
    docker kill <hash> # Force shutdown of the specified container
    8.從機器移除指定的容器
    docker rm <hash> # Remove the specified container from this machine
    9.移除機器所有的容器
    docker rm $(docker ps -a -q) # Remove all containers from this machine
    10.顯示本機包含的所有的鏡像
    docker images -a # Show all images on this machine
    11.從本季移除制定的鏡像
    docker rmi <imagename> # Remove the specified image from this machine
    12.從本機移除所有的鏡像
    docker rmi $(docker images -q) # Remove all images from this machine
    13.cli下登錄docker帳號
    docker login # Log in this CLI session using your Docker credentials
    14.標記要上傳到倉庫的鏡像
    docker tag <image> username/repository:tag # Tag <image> for upload to registry
    15.推送docker鏡像到倉庫
    docker push username/repository:tag # Upload tagged image to registry
    16.從倉庫運行docker鏡像
    docker run username/repository:tag # Run image from a registry

docker stack ls # List all running applications on this Docker host
docker stack deploy -c <composefile> <appname> # Run the specified Compose file
docker stack services <appname> # List the services associated with an app
docker stack ps <appname> # List the running containers associated with an app
docker stack rm <appname> # Tear down an application

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 一、Docker 簡介 Docker 兩個主要部件:Docker: 開源的容器虛擬化平臺Docker Hub: 用...
    R_X閱讀 4,409評論 0 27
  • 知道有些人費勁九牛二虎之力也裝不了Kitematic但你可以使用命令來使用docker。(假設你的終端可以執行do...
    _我和你一樣閱讀 10,518評論 0 0
  • docker http://www.runoob.com/docker/docker-install-python...
    點點漁火閱讀 837評論 0 4
  • 序 在上一篇基于Docker進行Golang開發文章中對Docker進行了安裝,并對如何用Docker進行Gola...
    技術學習閱讀 1,945評論 0 3
  • WuLiWIFI閱讀 299評論 0 0