Docker命令解读-二
来源:互联网 发布:虚幻4做的游戏好优化吗 编辑:程序博客网 时间:2024/06/05 04:21
title: Docker命令解读(二)
date: 2015-11-21 19:30:44
tags: docker
categories: Docker Commands
Docker命令解读系列文章将系统讲解Docker使用的命令,方便大家学习Docker的基本操作。在写这个系列文章的时候,主要参考了Docker官方的文档,有些内容是直接的翻译。原文档地址 Docker Docs
转载请注明出处
Docker
可以以两种模式启动,一种是client
,一种是daemon
,两者共用一个二进制文件。启动daemon
就要使用docker daemon
命令,使用docker daemon --help
命令可以查看它的可选参数。
Usage: docker daemon [OPTIONS]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 --default-gateway="" Container default gateway IPv4 address --default-gateway-v6="" Container default gateway IPv6 address --cluster-store="" URL of the distributed storage backend --cluster-advertise="" Address of the daemon instance on the cluster --cluster-store-opt=map[] Set cluster options --dns=[] DNS server to use --dns-opt=[] DNS options to use --dns-search=[] DNS search domains to use --default-ulimit=[] Set default ulimit settings for containers --exec-opt=[] Set exec driver options --exec-root="/var/run/docker" Root of the Docker execdriver --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 --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" Default driver for container logs --log-opt=[] Log driver specific options --mtu=0 Set the containers network MTU --disable-legacy-registry=false Do not contact legacy registries -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 --userland-proxy=true Use userland proxy for loopback traffic
docker daemon
用来管理所有的容器,是Docker
最核心的部件之一。可以使用docker daemon -D
启动DEBUG
模式
本章内容为:
* Daemon socket Options
* Daemon execdriver Options
* Daemon DNS Options
* Insecure Registries
* Legacy Registries
Daemon socket Options
Docker daemon
可以通过三种类型的socket监听Docker Remote API请求,分别是unix
,tcp
和fd
。
默认情况下,Docker
会在/var/run/docker.sock
下创建一个unix
套接字,这需要root
权限或者将当前用户加入了group docker
。
如果需要远程的访问Docker daemon
,就需要使用TCP
套接字,但需要注意的是,默认情况下,对Docker daemon
的访问是非加密的和没有认证的。为了保证安全,需要需要使用经过加密的HTTPS
套接字或者使用加密的安全web代理(secure web proxy
)。
你可以使用-H tcp://0.0.0.0:2375
以在所有的网络端口上监听2375接口,或者使用类似-H tcp://192.168.59.63:2375
在一个特定的网络接口上监听2375端口。2375接口使用非加密的连接,2376使用加密的连接。
Note:如果你要使用加密的HTTPS
连接,记住只支持TLS1.0和更高的版本,不支持SSLv3和以下的版本。
可以使用多个-H
标签来是Docker daemon
监听多个套接字,下面的例子监听一个unix socket
和两个tcp socket
:
docker daemon -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
docker client
会通过DOCKET_HOST
环境变量来设置自己的-H
标签值。
daemon存储驱动器选项 Docker daemon
支持多种分层的存储驱动器,包括aufs
,devicemapper
,btrfs
,zfs
和overlay
。 aufs
是最先被支持的一个,但是它几乎不可能被加入Linux
内核。aufs
是唯一一个支持容器间共享可执行二进制文件的存储驱动器。
Docker ecexdriver options
Docker
执行驱动器选项。目前Docker
默认的执行驱动器实现是libcontainer
,Docker
通过它与Linux内核的namespace
,cgroups
和SELinux
打交道。
你可以通过--exec-opt
标识来配置libcontainer
(native execdriver),这些选项都以native
作为前缀。
Daemon DNS Options
顾名思义,这个标识用来给所有的容器配置DNS服务器,命令格式为:
docker daemon --dns 8.8.8.8
也可以通过docker daemon --dns-search example.com
为容器设置DNS search domain
。
Insecure Registries
不安全的镜像服务。
Note:关于Docker
镜像服务,有几个概念:
首先是Registry
,它指一个提供Docker镜像服务的站点,我们翻译为服务
。 Repository
:它指一个提供某种镜像的仓库,如“chy/ubuntu”,它下面包括了各个版本的ubuntu镜像,如ubuntu12.04 ubuntu14.04等。
它们之间的关系为:一个Registry
包括多个Repository
,一个Repository
又包括多个镜像。
Docker
可以使用安全的或不安全的私有镜像Registry,所谓安全指镜像Registry使用了TLS
和CA证书。不安全的镜像Registry指或者没有使用TLS
或者其证书Docker daemon
无法识别。
默认情况下,Docker
要求除本地镜像Registry以外的所有镜像服务都要是安全的,否则无法进行通信。要与不安全的镜像Registry进行通信,需要在启动Docker daemon
时使用--insecure-registry
标识。有如下两种方式: --insecure-registry myregistry:5000
告诉Docker daemon
myregistry:5000是不安全的;--insecure-registry 10.1.0.0/16
告诉Docker daemon
子网中的所有镜像Registry都是不安全的。
如果一个不安全的镜像Registry没有被标记为不安全,那么docker pull
,docker push
,docker search
命令会返回一个错误告诉用户或者使用安全的镜像Registry或者将其标记为不安全。
本地的镜像Registry默认被标记为不安全的,但这可能在未来的版本中改变。
使用了--insecure-registry
标识,意味着与其通信是不加密的,这在运行一个本地的镜像Registry时很有用(省去一些额外开销)。但最好只用来进行测试,因为可能会产生安全问题。
Legacy Registry
旧版本的Registry,也就是使用V1
协议的Registry,目前比较新的协议是V2。--disable-legacy-registry
标识指定Docker daemon
只能和使用了V2协议的Registry进行通信。这样,当执行pull
,push
,login
命令的时候将不会尝试和V1 Registry通信,但search
命令依然可以在V1 Registry上使用。
- Docker命令解读-二
- Docker命令解读-一
- Docker命令解读-三
- Docker命令解读-四
- Docker命令解读-五
- Docker命令解读-六
- Docker命令解读-七
- Docker命令解读-八
- Docker命令学习(二)
- docker命令介绍(二)
- Docker源码分析(二):Docker Client创建与命令执行
- Docker源码分析(二):Docker Client创建与命令执行
- Docker源码分析(二):Docker Client创建与命令执行
- Docker 菜鸟笔记(二)Docker 安装与常见命令
- Docker源码分析(二):Docker Client创建与命令执行
- 二.docker镜像基本命令
- docker总结二——命令
- Docker网络深度解读
- JavaScript设置按下enter键后执行函数
- 微服务实战:深入微服务架构的进程间通信
- STL 基础学习总结
- Maven Intellij 配置下载镜像
- shell-四(数组和函数)
- Docker命令解读-二
- Android优化(三)_延迟电池续航时间
- 编程总结(四)C++中的前置声明
- jsp 前端防止 xss 注入攻击
- Java并发编程:Synchronized及其实现原理
- vue2.0总结 --- vue使用过程中的常见问题
- 56
- WAMPServer自定义监听端口号
- 打造网络营销利器-第6篇-外链推广 网站优化进阶