Docker常用命令

Docker常用命令

Docker命令详解:

attach     附加到一个运行的容器上面
      --no-stdin=false Do not attach stdin
      --sig-proxy=true Proxify all received signal to the process (even in non-tty mode)
        
        attach命令允许你查看或者影响一个运行的容器。你可以在同一时间attach同一个容器。你也可以从一个容器中脱离出来,是从CTRL-C。

 build     根据Dockerfile 构建出一个容器
      --no-cache=false Do not use cache when building the image
      -q, --quiet=false Suppress the verbose output generated by the containers
      --rm=true Remove intermediate containers after a successful build
      -t, --tag="" Repository name (and optionally a tag) to be applied to the resulting image in case of success


 commit     根据现有的容器的改变创建一个新的容器镜像
      -a, --author="" Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
      -m, --message="" Commit message

 cp     从容器里面拷贝文件/目录到本地一个路径
    
diff    列出一个容器里面被改变的文件或者目录,list列表会显示出三种事件,A 增加的,D 删除的,C 被改变的。

events     从容器中获取实时事件
      --since="" Show all events created since timestamp
      --until="" Stream events until this timestamp

export     把容器的内容打包成tar包输出到标准输出


history     显示一个镜像的历史
      --no-trunc=false Don't truncate output
      -q, --quiet=false Only show numeric IDs

images    列出镜像列表  
      -a, --all=false Show all images (by default filter out the intermediate image layers)
      --no-trunc=false Don't truncate output
      -q, --quiet=false Only show numeric IDs

import        从一个tar包创建一个新的镜像 
      Usage: docker import URL|- [REPOSITORY[:TAG]]
       URL必须是以http开头的指向一个单独的tar包出现的文件系统。如果你想从本地目录或者tar包导入,则使用‘-’从标准输入代替数据来源

info     显示docker系统的信息

inspect     返回系统或者镜像的一些低层次的信息,默认会返回一些JSON格式的信息,如果你指定其他输出格式,也会显示其他格式的输出
                 http://golang.org/pkg/text/template/
    
kill     kill一个运行的容器,发送SIGKILL信号,或者其他你指定的信号

load     在标准输入加载一个tar包格式的镜像
        -i, --input="" Read from a tar archive file, instead of STDIN

login     登陆registry server
      -e, --email="" Email
      -p, --password="" Password
      -u, --username="" Username

logs     从一个容器中取日志
      -f, --follow=false Follow log output
      -t, --timestamps=false Show timestamps

port     查看公共的端口经过NATA映射到私有的哪个端口

ps     显示容器,默认只显示当前在运行的容器。
      -a, --all=false Show all containers. Only running containers are shown by default.
      --before="" Show only container created before Id or Name, include non-running ones.
      -l, --latest=false Show only the latest created container, include non-running ones.
      -n=-1 Show n last created containers, include non-running ones.
      --no-trunc=false Don't truncate output
      -q, --quiet=false Only display numeric IDs
      -s, --size=false Display sizes
      --since="" Show only containers created since Id or Name, include non-running ones.

pull     从docker的registry server 拉取镜像

push     推一个镜像到docker registry server

restart     重启一个正在运行的容器
        -t, --time=10 Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10

rm     删除一个或者多个容器
          -f, --force=false Force removal of running container
          -l, --link=false Remove the specified link and not the underlying container
          -v, --volumes=false Remove the volumes associated to the container

rmi     删除一个或者多个镜像
          -f, --force=false Force
          --no-prune=false Do not delete untagged parents

run     在一个新的容器中运行一个命令
          -a, --attach=[] Attach to stdin, stdout or stderr.
          -c, --cpu-shares=0 CPU shares (relative weight)
          --cidfile="" Write the container ID to the file
          -d, --detach=false Detached mode: Run container in the background, print new container id
          --dns=[] Set custom dns servers
          --dns-search=[] Set custom dns search domains
          -e, --env=[] Set environment variables
          --entrypoint="" Overwrite the default entrypoint of the image
          --env-file=[] Read in a line delimited file of ENV variables
          --expose=[] Expose a port from the container without publishing it to your host
          -h, --hostname="" Container host name
          -i, --interactive=false Keep stdin open even if not attached
          --link=[] Add link to another container (name:alias)
          --lxc-conf=[] (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
          -m, --memory="" Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
          --name="" Assign a name to the container
          --net="bridge" Set the Network mode for the container
                               'bridge': creates a new network stack for the container on the docker bridge
                               'none': no networking for this container
                               'container:<name|id>': reuses another container network stack
                               'host': use the host network stack inside the contaner
          -P, --publish-all=false Publish all exposed ports to the host interfaces
          -p, --publish=[] Publish a container's port to the host
                               format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort
                               (use 'docker port' to see the actual mapping)
          --privileged=false Give extended privileges to this container
          --rm=false Automatically remove the container when it exits (incompatible with -d)
          --sig-proxy=true Proxify all received signal to the process (even in non-tty mode)
          -t, --tty=false Allocate a pseudo-tty
          -u, --user="" Username or UID
          -v, --volume=[] Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)
          --volumes-from=[] Mount volumes from the specified container(s)
          -w, --workdir="" Working directory inside the container

save     保存镜像到一个tar包
          -o, --output="" Write to an file, instead of STDOUT

search     在docker index中寻找镜像
          --no-trunc=false Don't truncate output
          -s, --stars=0 Only displays with at least xxx stars
          -t, --trusted=false Only show trusted builds

start     启动一个停止的容器
          -a, --attach=false Attach container's stdout/stderr and forward all signals to the process
          -i, --interactive=false Attach container's stdin

stop     停止一个容器
        -t, --time=10 Number of seconds to wait for the container to stop before killing it.

tag     给repository 中的镜像进行标记
          -f, --force=false Force

top     显示一个运行的容器里面的进程信息

version     显示docker的版本信息

wait     阻止容器直到容器停止,然后打印退出码

转载于:https://my.oschina.net/guol/blog/270950

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/109816.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Docker 离线安装_docker官方中文文档

    Docker 离线安装_docker官方中文文档docker离线安装流程

    2022年9月26日
    3
  • docker部署vue项目_docker部署java

    docker部署vue项目_docker部署java第一步:vue项目打包成dist。npmrunbuild第二步:构建Dockerfile#设置基础镜像,这里使用最新的nginx镜像,前面已经拉取过了FROMnginx#将dist文件中的内容复制到/usr/share/nginx/html/这个目录下面COPYdist//usr/share/nginx/html/第三步:安装nginxdockerpullnginxdockerrun–namenginx-d-p4030:8.

    2022年10月19日
    3
  • Docker(四):使用Docker部署tomcat、mysql、nginx静态服务器

    Docker(四):使用Docker部署tomcat、mysql、nginx静态服务器

    2021年9月26日
    79
  • Docker Compose详解

    Docker Compose详解使用 DockerCompos 预计阅读时间 11 分钟 DockerCompos 是一种用于帮助定义和共享多容器应用程序的工具 使用 Compose 我们可以创建一个 YAML 文件来定义服务 并且使用一个命令 可以启动所有内容或将其全部关闭 使用 Compose 的最大优势是您可以在一个文件中定义您的应用程序堆栈 将其保存在项目 repo 的根目录中 它现在是版本控制的 并且可以轻松地让其他人为您的项目做出贡献 有人只需要克隆您的存储库并启动撰写应用程序 事实上 你现在可能会在 GitHub Gi

    2025年6月17日
    2
  • docker(3)快速搭建centos7-python3.6环境[通俗易懂]

    docker(3)快速搭建centos7-python3.6环境[通俗易懂]前言当我们在一台电脑上搭建了python3.6的环境,下次换台电脑,又得重新搭建一次,设置环境变量等操作。好不容易安装好,一会提示pip不是内部或外部命令,一会又提示pip:commandno

    2022年7月30日
    8
  • Docker安装RabbitMQ并安装延时队列插件

    Docker安装RabbitMQ并安装延时队列插件一、RabbitMQ简介RabbitMQ是由erlang语言开发,基于AMQP(AdvancedMessageQueue高级消息队列协议)协议实现的消息队列,它是一种应用程序之间的通信方法,消息队列在分布式系统开发中应用非常广泛。二、docker安装RabbitMQ1、搜索镜像dockersearchrabbitmq2、拉取并运行容器dockerrun-dit–namerabbitmq-eRABBITMQ_DEFAULT_USER=guest-eR

    2022年5月10日
    98

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号