码迷,mamicode.com
首页 > 其他好文 > 详细

使用容器与命令

时间:2015-08-03 14:56:33      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:ubuntu   客户端   标示   前台   用户   

上一节中我们使用Docker run 命令启用了容器

  • 我们在前台进行了容器交互

  • 在后台进程运行容器

在这个过程中我们了解了几个Docker 命令:


  • docker ps 列出容器

  • docker logs 显示容器标准输出

  • docker stop 停止正在运行的容器


提示:我们有另外一种方法来学习docker命令,与用户交互

docker客户端非常简单,你可使用docker的每一个标示和参数组合来进行你的操作。

# Usage:  [sudo] docker [flags] [command] [arguments] ..

# Example:

$ docker run -i -t ubuntu /bin/bash

这时候我们使用docker version命令来返回安装的docker客户端和进程信息


Client version: 0.8.0                客户端版本信息Go version (client): go1.2           Go版本信息Git commit (client): cc3a8c8      Server version: 0.8.0Git commit (server): cc3a8c8Go version (server): go1.2Last stable version: 0.8.0

让我们使用Docker --help命令来看看docker详细的参数

[root@docker ~]# docker --help

Usage: docker [OPTIONS] COMMAND [arg...]


A self-sufficient runtime for linux containers.


Options:

  --api-cors-header=                   Set CORS headers in the remote API

  -b, --bridge=                        Attach containers to a network bridge

  --bip=                               Specify network bridge IP

  -D, --debug=false                    Enable debug mode

  -d, --daemon=false                   Enable daemon mode

  --default-ulimit=[]                  Set default ulimits for containers

  --dns=[]                             DNS server to use

  --dns-search=[]                      DNS search domains to use

  -e, --exec-driver=native             Exec driver to use

  --fixed-cidr=                        IPv4 subnet for fixed IPs

  --fixed-cidr-v6=                     IPv6 subnet for fixed IPs

  -G, --group=docker                   Group for the unix socket

  -g, --graph=/var/lib/docker          Root of the Docker runtime

  -H, --host=[]                        Daemon socket(s) to connect to

  -h, --help=false                     Print usage

  --icc=true                           Enable inter-container communication

  --insecure-registry=[]               Enable insecure registry communication

  --ip=0.0.0.0                         Default IP when binding container ports

  --ip-forward=true                    Enable net.ipv4.ip_forward

  --ip-masq=true                       Enable IP masquerading

  --iptables=true                      Enable addition of iptables rules

  --ipv6=false                         Enable IPv6 networking

  -l, --log-level=info                 Set the logging level

  --label=[]                           Set key=value labels to the daemon

  --log-driver=json-file               Containers logging driver

  --mtu=0                              Set the containers network MTU

  -p, --pidfile=/var/run/docker.pid    Path to use for daemon PID file

  --registry-mirror=[]                 Preferred Docker registry mirror

  -s, --storage-driver=                Storage driver to use

  --selinux-enabled=false              Enable selinux support

  --storage-opt=[]                     Set storage driver options

  --tls=false                          Use TLS; implied by --tlsverify

  --tlscacert=~/.docker/ca.pem         Trust certs signed only by this CA

  --tlscert=~/.docker/cert.pem         Path to TLS certificate file

  --tlskey=~/.docker/key.pem           Path to TLS key file

  --tlsverify=false                    Use TLS and verify the remote

  -v, --version=false                  Print version information and quit


Commands:

    attach    Attach to a running container

    build     Build an image from a Dockerfile

    commit    Create a new image from a container‘s changes

    cp        Copy files/folders from a container‘s filesystem to the host path

    create    Create a new container

    diff      Inspect changes on a container‘s filesystem

    events    Get real time events from the server

    exec      Run a command in a running container

    export    Stream the contents of a container as a tar archive

    history   Show the history of an image

    images    List images

    import    Create a new filesystem image from the contents of a tarball

    info      Display system-wide information

    inspect   Return low-level information on a container or image

    kill      Kill a running container

    load      Load an image from a tar archive

    login     Register or log in to a Docker registry server

    logout    Log out from a Docker registry server

    logs      Fetch the logs of a container

    port      Lookup the public-facing port that is NAT-ed to PRIVATE_PORT

    pause     Pause all processes within a container

    ps        List containers

    pull      Pull an image or a repository from a Docker registry server

    push      Push an image or a repository to a Docker registry server

    rename    Rename an existing container

    restart   Restart a running container

    rm        Remove one or more containers

    rmi       Remove one or more images

    run       Run a command in a new container

    save      Save an image to a tar archive

    search    Search for an image on the Docker Hub

    start     Start a stopped container

    stats     Display a stream of a containers‘ resource usage statistics

    stop      Stop a running container

    tag       Tag an image into a repository

    top       Lookup the running processes of a container

    unpause   Unpause a paused container

    version   Show the Docker version information

    wait      Block until a container stops, then print its exit code


Run ‘docker COMMAND --help‘ for more information on a command.  

更加详细的请使用docker  参数  --help

例如:

[root@docker ~]# docker logs --help

Usage: docker logs [OPTIONS] CONTAINER

Fetch the logs of a container

  -f, --follow=false        Follow log output

  --help=false              Print usage

  -t, --timestamps=false    Show timestamps

  --tail=all                Number of lines to show from the end of the logs


本文出自 “个性的水瓶” 博客,请务必保留此出处http://tanxm.blog.51cto.com/2442356/1681197

使用容器与命令

标签:ubuntu   客户端   标示   前台   用户   

原文地址:http://tanxm.blog.51cto.com/2442356/1681197

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!