zoukankan      html  css  js  c++  java
  • docker常用命令理解

    docker help
    Commands: attach Attach local standard input, output, and error streams to a running container //重新进入一个运行的容器 build Build an image from a Dockerfile commit Create a new image from a container
    's changes //可以自定义一个容器并生成镜像提交
    docker commit -a="author" -m="description"  容器id 要创建的目标镜像名:[标签名]
      cp          Copy files/folders between a container and the local filesystem
      create      Create a new container
      diff        Inspect changes to files or directories on a container's filesystem
      events      Get real time events from the server
      exec        Run a command in a running container
      export      Export a container's filesystem as a tar archive
      history     Show the history of an image
      images      List images         //列出本地的镜像
      import      Import the contents from a tarball to create a filesystem image
      info        Display system-wide information
      inspect     Return low-level information on Docker objects
      kill        Kill one or more running containers
      load        Load an image from a tar archive or STDIN
      login       Log in to a Docker registry
      logout      Log out from a Docker registry
      logs        Fetch the logs of a container
      pause       Pause all processes within one or more containers
      port        List port mappings or a specific mapping for the container
      ps          List containers
      pull        Pull an image or a repository from a registry
      push        Push an image or a repository to a registry
      rename      Rename a container
      restart     Restart one or more containers
      rm          Remove one or more containers    //删除容器
      rmi         Remove one or more images      //docker rmi -f 镜像名称
      run         Run a command in a new container
      save        Save one or more images to a tar archive (streamed to STDOUT by default)
      search      Search the Docker Hub for images
      start       Start one or more stopped containers
      stats       Display a live stream of container(s) resource usage statistics
      stop        Stop one or more running containers
      tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
      top         Display the running processes of a container
      unpause     Unpause all processes within one or more containers
      update      Update configuration of one or more containers
      version     Show the Docker version information
      wait        Block until one or more containers stop, then print their exit codes
    
    Run 'docker COMMAND --help' for more information on a command.

     

    docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
    OPTIONS说明:
    -a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三项;
    -d: 后台运行容器,并返回容器ID;  
    -i: 以交互模式运行容器,通常与 -t 同时使用;
    -p: 端口映射,格式为:主机(宿主)端口:容器端口
    -t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
    --name="nginx-lb": 为容器指定一个名称;
    --dns 8.8.8.8: 指定容器使用的DNS服务器,默认和宿主一致;
    --dns-search example.com: 指定容器DNS搜索域名,默认和宿主一致;
    -h "mars": 指定容器的hostname;
    -e username="ritchie": 设置环境变量;
    --env-file=[]: 从指定文件读入环境变量;
    --cpuset="0-2" or --cpuset="0,1,2": 绑定容器到指定CPU运行;
    -m :设置容器使用内存最大值;
    --net="bridge": 指定容器的网络连接类型,支持 bridge/host/none/container: 四种类型;
    --link=[]: 添加链接到另一个容器;
    --expose=[]: 开放一个端口或一组端口;


    ctrl+p+q:容器不停止而退出
    exit:停止并退出容器
    docker attach ...id 重新进入未关闭的容器
    docker exec -it  ...id /bin/bash 进入容器并返回一个shell


    将宿主机的目录与docker容器中的目录相关联起来,目录挂载:

    docker run -it -v /宿主机绝对路径目录:/容器内目录  镜像名 

      


    docker镜像    联合文件系统    以tomcat为例

     


     参考:docker命令大全

  • 相关阅读:
    nodejs cheerio模块提取html页面内容
    简短的perl程序
    laravel 模型操作
    Laravel 学习笔记
    记录一下应该养成的好习惯
    phpstudy设置允许远程访问mysql数据库
    删除专家账号,要注意删干净
    使用 Composer 安装Laravel扩展包的几种方法
    上传文件太大,后台无法获取到文件的问题
    在Laravel中使用mongoDB
  • 原文地址:https://www.cnblogs.com/ustc-anmin/p/10859884.html
Copyright © 2011-2022 走看看