docker命令

作者: think_lonely | 来源:发表于2017-05-17 17:33 被阅读3次

    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命令

        本文链接:https://www.haomeiwen.com/subject/bundxxtx.html