Docker官方为了让用户高速了解Docker,提供了一个交互式教程,旨在帮助用户掌握Docker命令行的用法。

Docker 命令行

以下对Docker的命令清单进行简单的介绍,具体内容在兴许章节具体介绍。

能够通过执行 docker ,或者 docker help 命令得到命令行的帮助信息(我们还是以 vmware 上的 coreos 为操作环境,如无特殊说明后文都採用这个环境):

core@localhost ~ $ docker
Usage: docker [OPTIONS] COMMAND [arg...]
-H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use A self-sufficient runtime for linux containers. 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
diff Inspect changes on a container's filesystem
events Get real time events from the server
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
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
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
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
  • 当中 info、version是系统环境信息相关的命令
  • events、history、logs 是日志信息相关的命令
  • login\pull\push\search是DockerHub服务相关的命令
  • 其余都是日常维护相关的命令

命令语法

基本用法:命令+參数

core@localhost ~ $ docker info
Containers: 7
Images: 123
Storage Driver: btrfs
Execution Driver: native-0.2
Kernel Version: 3.16.2+
Operating System: CoreOS 444.0.0
core@localhost ~ $ docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.1
Git commit (client): fa7b24f
OS/Arch (client): linux/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.1
Git commit (server): fa7b24f

单个字符的參数能够放在一起:

core@localhost ~ $ docker run -t -i ubuntu:14.04 /bin/bash
#使用分开的參数
root@d512e393fc74:/# exit
exit
core@localhost ~ $ docker run -ti ubuntu:14.04 /bin/bash
#将当个支付的參数放在一起
root@d170dacef325:/# exit
exit
core@localhost ~ $ docker rm d51 d17
#多个參数放在一行
d51
d17
core@localhost ~ $

Docker 后台进程參数

參数 介绍
--api-enable-cors=false 远程API调用。
-b, --bridge="" 桥接一个系统上的网桥设备到 Docker 容器里,当使用 none 能够停用容器里的网络
--bip="" 使用 CIDR 地址来设定网络桥的 IP。此參数和 -b 不能一起使用。

-D, --debug=false 开启Debug模式。比如:docker -d -D
-d, --daemon=false 开启Daemon模式。

--dns=[] 设置容器使用DNS服务器。比如: docker -d --dns 8.8.8.8
-dns-search=[] 设置容器使用指定的DNS搜索域名。如: docker -d --dns-search example.com
--exec-driver="native" 设置容器使用指定的执行时驱动。

如:docker -d -e lxc

-G, --group="docker" 在后台执行模式下。赋予指定的Group到对应的unix socket上。

注意,当此參数 --group 赋予空字符串时。将去除组信息

-g, --graph="/var/lib/docker" 设置Docker执行时根文件夹
-H, --host=[] 设置后台模式下指定socket绑定,能够绑定一个或多个 tcp://host:port, unix:///path/to/socket, fd://* 或 fd://socketfd。如:$ docker -H tcp://0.0.0.0:2375 ps 或者$ export DOCKER_HOST="tcp://0.0.0.0:2375"$ docker ps
-icc=true 设置启用内联容器的通信。
--ip="0.0.0.0" 设置容器绑定IP时使用的默认IP地址
--ip-forward=true 设置启动容器的 net.ipv4.ip_forward
--iptables=true 设置启动Docker容器自己定义的iptable规则
--mtu=0 设置容器网络的MTU值,假设没有这个參数,选用默认 route MTU。假设没有默认route。就设置成常量值 1500。
-p, --pidfile="/var/run/docker.pid" 设置后台进程PID文件路径。

-r, --restart=true 设置重新启动之前执行中的容器
-s, --storage-driver="" 设置容器执行时使用指定的存储驱动,如,指定使用devicemapper,能够这样:docker -d -s devicemapper
--selinux-enabled=false 设置启用selinux支持
--storage-opt=[] 设置存储驱动的參数

Docker 配置文件位置

Docker 的配置文件能够设置大部分的后台进程參数,在各个操作系统中的存放位置不一致

在 ubuntu 中的位置是:/etc/default/docker

在 centos 中的位置是:/etc/sysconfig/docker

很多其它内容请关注 http://www.dockerpool.com

Docker 命令行和后台參数的更多相关文章

  1. docker命令和后台参数

    Docker官方为了让用户快速了解Docker,提供了一个 交互式教程 ,旨在帮助用户掌握Docker命令行的使用方法. Docker 命令行 下面对Docker的命令清单进行简单的介绍,详细内容在后 ...

  2. grep命令经常使用參数及使用方法

    1.grep介绍 grep命令是Linux系统中一种强大的文本搜索工具,它能使用正則表達式搜索文本.并把匹 配的行打印出来.grep全称Global Regular Expression Print, ...

  3. Python命令行选项參数解析策略

    概述 在Python的项目开发过程中,我们有时须要为程序提供一些能够通过命令行进行调用的接口.只是,并非直接使用 command + 当前文件 就ok的,我们须要对其设置可选的各种各样的操作类型.所以 ...

  4. Python进阶(三十五)-Fiddler命令行和HTTP断点调试

    Python进阶(三十五)-Fiddler命令行和HTTP断点调试 一. Fiddler内置命令   上一节(使用Fiddler进行抓包分析)中,介绍到,在web session(与我们通常所说的se ...

  5. kettle參数、变量具体解说

    kettle參数.变量具体解说 kettle 3.2 曾经的版本号里仅仅有 variable 和 argument,kettle 3.2 中.又引入了 parameter 概念.variable 即e ...

  6. ORACLE 參数文件介绍

    ORACLE数据库启动以后.通过select * from v$parameter这个语句能够查看到oracle数据库使用的全部參数. 对于oracle的參数文件,分为spfile 二进制文件和pfi ...

  7. grep命令參数及使用方法

    功能说明:查找文件中符合条件的字符串. 语 法:grep [-abcEFGhHilLnqrsvVwxy][-A<显示列数>][-B<显示列数>][-C<显示列数>] ...

  8. 命令行參数选项处理:getopt()及getopt_long()函数使用

         在执行某个程序的时候,我们通常使用命令行參数来进行配置其行为.命令行选项和參数控制 UNIX 程序,告知它们怎样动作. 当 gcc的程序启动代码调用我们的入口函数 main(int argc ...

  9. Hadoop Ls命令添加显示条数限制參数

    前言 在hadoop的FsShell命令中,预计非常多人比較经常使用的就是hadoop fs -ls,-lsr,-cat等等这种与Linux系统中差点儿一致的文件系统相关的命令.可是细致想想,这里还是 ...

随机推荐

  1. Boost.Asio c++ 网络编程翻译(16)

    TCP异步服务端 核心功能和同步服务端的功能类似,例如以下: class talk_to_client : public boost::enable_shared_from_this<talk_ ...

  2. nyist oj 115 城市平乱 (最短路径)

    城市平乱 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描写叙述 南将军统领着N个部队.这N个部队分别驻扎在N个不同的城市. 他在用这N个部队维护着M个城市的治安.这M个城市 ...

  3. 【iOS开发系列】UIDevice设备信息

    [1] 推断是否是横向屏: BOOL b=UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation); 获取设备uniqu ...

  4. C#趣味程序---三色球问题

    问题:若一个口袋中放有12个球,3红3白和6黑,问从袋中随意取8个球,有多少种不同的颜色搭配? using System; namespace ConsoleApplication1 { class ...

  5. HDU 1269 -- 迷宫城堡【有向图求SCC的数目 &amp;&amp; 模板】

    迷宫城堡 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  6. Codeforces Round #282 (Div. 1)B. Obsessive String KMP+DP

    B. Obsessive String   Hamed has recently found a string t and suddenly became quite fond of it. He s ...

  7. 什么是BOM头(字节顺序标记(ByteOrderMark))

    在utf-8编码文件中BOM在文件头部,占用三个字节,用来标示该文件属于utf-8编码,现在已经有很多软件识别bom头,但是还有些不能识别bom头,比如PHP就不能识别bom头,这也是用记事本编辑ut ...

  8. Ubuntu16.04系统安装搜狗输入法

    前言:正常双击.deb软件包安装搜狗输入法会有bug,需要按照下面操作进行消除错误. 一.下载搜狗输入法Linux版软件包 下载地址为:http://pinyin.sogou.com/linux/ , ...

  9. [原创]c语言中const与指针的用法

    最近一直在准备笔试,补补大一大二欠下的课.复习c语言时碰见这么个题:   1 2 3 4 5 int a=248, b=4; int const c=21; const int *d=&a;  ...

  10. Unity 三维软件单位导入资源单位比例

    三维软件 内部米制尺寸/m 默认设置导入unity中的尺寸/m 与unity单位比例 Maya 1 100 1:100 3DS MAX 1 0.01 100:1 Cinema 4D 1 100 1:1 ...