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,526评论 0 0
  • docker http://www.runoob.com/docker/docker-install-python...
    点点渔火阅读 838评论 0 4
  • 序 在上一篇基于Docker进行Golang开发文章中对Docker进行了安装,并对如何用Docker进行Gola...
    技术学习阅读 1,945评论 0 3
  • WuLiWIFI阅读 299评论 0 0