docker daemon命令-docker运行可指定项详解

daemon 这是docker 操作中十分常用的命令指定项

Usage of docker:--api-enable-cors=falseEnable CORS headers in the remote api 在远程api中操作启用CORSAPI 

-b,--bridge=""Attach containers to a pre-existing network bridge
use'none' to disable container networking 桥接容器
--bip=""Usethis CIDR notation address for the network bridge's IP, not compatible with -b
-D, --debug=false Enable debug mode 启动调试模式
-d, --daemon=false Enable daemon mode 启动daemon模式
--dns=[] Force Docker to use specific DNS servers 强制使用指定DNS
--dns-search=[] Force Docker to use specific DNS search domains 强制使用指定dns 域
-e, --exec-driver="native" Force the Docker runtime to use a specific exec driver
-G, --group="docker" Group to assign the unix socket specified by -H when running in daemon mode
use '' (the empty string) to disable setting of a group 指定群组可用socket
-g, --graph="/var/lib/docker" Path to use as the root of the Docker runtime
-H, --host=[] The socket(s) to bind to in daemon mode
specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.
--icc=true Enable inter-container communication
--ip="" Default IP address to use when binding container ports 指定ip
--ip-forward=true Enable net.ipv4.ip_forward ip转发
--iptables=true Enable Docker'
s addition of iptables rules 使用防火墙iptables
--mtu=0Set the containers network MTU
ifno value is provided:default to the default route MTU or1500ifnodefault route is available
-p,--pidfile="/var/run/"Path to usefor daemon PID file 指定pid
-r,--restart=trueRestart previously running containers 重启
-s,--storage-driver=""Force the Docker runtime to use a specific storage driver
--selinux-enabled=falseEnable selinux support selinux 使用
--storage-opt=[]Set storage driver options
--tls=falseUse TLS; implied by tls-verify flags
--tlscacert="/home/sven/.docker/ca.pem"Trust only remotes providing a certificate signedby the CA given here 使用证书
--tlscert="/home/sven/.docker/cert.pem"Path to TLS certificate file 使用证书
--tlskey="/home/sven/.docker/key.pem"Path to TLS key file 使用key
--tlsverify=falseUse TLS and verify the remote (daemon: verify client, client: verify daemon)-v,--version=falsePrint version information and quit

Options with [] may be specified multiple times. 命令中包含[] 为特殊命令

启动docker时使用 -d 标识,则可以自动启动daemon模式.

强制指定docker 使用指定挂载设备作为存储设备 docker -d -s devicemapper.

设置dns使用 docker -d --dns

设置dns搜索域 docker -d --dns-search

输出调试log docker -d -D.

使用lxc作为可执行驱动 docker -d -e lxc.

The docker client will also honor the DOCKER_HOST environment variable to set the -H flag for the client.

$ docker -H tcp:// ps# or

export DOCKER_HOST="tcp://"
$ docker ps
# both are equal

借助 systemd socket activation, 使用docker daemon  命令为 docker -d -H fd://. Using fd:// will work perfectly for most setups but you can also specify individual sockets too docker -d -H fd://3. 如果指定socket不存在,则docker容器就会退出运行。你可以在这里找到使用systemd的的docker源码案例 docker source tree.

docker还支持以软链接方式绑定缓存目录 (/var/lib/docker) and for /tmp. TMPDIR 下面是示例代码:

TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1# orexport TMPDIR=/mnt/disk2/tmp

/usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/dock