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

docker命令和后台参数的更多相关文章

  1. Docker 命令行和后台參数

    Docker官方为了让用户高速了解Docker,提供了一个交互式教程,旨在帮助用户掌握Docker命令行的用法. Docker 命令行 以下对Docker的命令清单进行简单的介绍,具体内容在兴许章节具 ...

  2. docker操作命令大全和后台参数

    一.命令行 可以通过运行 docker ,或者 docker help 命令得到命令行的帮助信息(我们以 CentOS 为操作环境为例): [root@iz2ze2bn5x2wqxdeq65wlpz ...

  3. Docker命令学习

    今天更换腾讯云系统的时候发现了多了个CoreOS,据说是专门运行docker的轻量系统,顺便学习一下docker命令. 1. docker version 显示 Docker 版本信息. 2. doc ...

  4. Docker命令详解

    Docker命令详解   最近学习Docker,将docker所有命令实验了一番,特整理如下: # docker --help Usage: docker [OPTIONS] COMMAND [arg ...

  5. Docker 命令(二)

    Docker 入门 启动docker systemctl start docker 帮助命令 docker --help docker [Commands] --help   例:docker run ...

  6. docker命令汇总

    docker命令汇总 序号 类别 简述 命令 功能 说明 1 整体管理 安装 yum install docker-engine centos上安装docker Ubuntu上安装dockerapt- ...

  7. Docker命令详解(run篇)

    命令格式:docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Usage: Run a command in a new container 中文意思为:通过r ...

  8. 深入浅出Docker(二):Docker命令行探秘

    1. Docker命令行 Docker官方为了让用户快速了解Docker,提供了一个交互式教程,旨在帮助用户掌握Docker命令行的使用方法.但是由于Docker技术的快速发展,此交互式教程已经无法满 ...

  9. Docker 命令详解(run篇)

    参考:https://www.cnblogs.com/yfalcon/p/9044246.html 命令格式:docker run [OPTIONS] IMAGE [COMMAND] [ARG...] ...

随机推荐

  1. IoC in Spring

    写两个关于Spring中使用IoC的小例子,一个是半动态创建Bean,另一个是全动态创建Bean,它们适合不同的应用场景. 一.半动态:在一个实际项目中遇到过这样的问题,项目组开发的某个系统具备在LE ...

  2. 通过VNC Viewer使用VMware虚拟机的远程桌面连接

    本文转自:http://www.14blog.com/archives/185 要在VMware虚拟机中使用远程桌面连接?方法有两个:一种是在虚拟机中做“端口映射”,当然,这个稍显复杂(虚拟机端口映射 ...

  3. 初识B/S结构编程技术

    B/S结构编程语言 ASP(Active Server Page 动态服务器页面)技术 微软早期推出的B/S编程技术,出现在JSP和ASP.NET之前,PHP当时也很不稳定.ASP之前,动态网站使用G ...

  4. RocketMQ源码 — 二、 NameServer

    NameServer 作用:Producer和Consumer获取Broker的地址 目的:解耦Broker和Producer.Consumer 原理:使用netty作为通信工具,监听指定端口,如果是 ...

  5. CodeForces 213B Numbers

    $dp$,组合数. $dp[i][j]$表示只用数字$i$,$i+1$,$i+2$......,$9$,凑成长度为$j$的并且数字$i$到$9$符合要求的方案数.只要枚举数字$i$用几个就可以转移了. ...

  6. jQuery 之玩转 checkbox

    <!DOCTYPE html> <html> <head> <title></title> <meta charset="u ...

  7. To the end

    身为一名初二狗的我也走过了半年.不管怎么说人生中也没有几个半年嘛.从九月到现在快四个月了,我也离中考越来越近了/郁闷/.但是还是要好好过唔.不过我想起这半学期还是挺充实的,至少没有浪费太多的时间.有些 ...

  8. CentOS7配置OpenCV2.4.13

    以管理员身份运行su root输入密码 安装依赖包 yum install gcc gcc-c++ gtk2-devel gimp-devel gimp-devel-tools gimp-help-b ...

  9. jQuery基础教程第四版练习答案

    第二章 1. $('#selected-plays>li>ul>li').nextAll().addBack().addClass('special'); 2. $('table') ...

  10. ionic for mac 新建与调试

    ionic官网:http://ionicframework.com/ 首先需要下载node.js,建议node管理方式请先详细查看林一篇博客http://www.cnblogs.com/minyc/p ...