2.1 docker 启动容器的时候可以使用的一些选项 和配置
来源:互联网 发布:陕西天互数据 编辑:程序博客网 时间:2024/06/11 03:17
docker守护进程的配置和操作模式:
docker -d [OPTIONS]
-d 以后台方式运行容器。
下面是容器创建时的一些配置,按需添加。初学者可以简单看看,以后需要再来查找。
运行相关:
-D, --debug=false
-e,--exec-driver="native"
-p,--pidfile="/var/run/docker.pid"
服务器相关:
-G,--group="docker"
-H,--host=[]
--tls=false
RemoteAPI相关:
--api-enable-cors=false
存储相关:
-S,--storage-driver=""
--selinux-enabled=false
--storage-opt=[]
网络设置相关:
-b,--bridge="" 设置自定义网桥
--bip=""
--dns=[]
--ip=0.0.0.0
Security Options
通过--security-opt选项,运行容器时用户可自定义 SELinux 和 AppArmor 卷标和配置。
$ docker run --security-opt label:type:svirt_apache -i -t centos \ bash
上例只允许容器监听在 Apache 端口,这个选项的好处是用户不需要运行 docker 的时候指定--privileged选项,降低安全风险
启动配置文件
Ubuntu: /etc/default/docker
CentOS: /etc/sysconfig/docker
如果没有配置文件,可以直接编辑:
vim /lib/systemd/system/docker.service
里面的ExecStart就是启动配置,默认是:
ExecStart=/usr/bin/docker -H fd://
我们可以加几个配置:
ExecStart=/usr/bin/docker -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H fd:// --label name=server_1
然后重启:
systemctl daemon-reload
systemctl restart docker.service
# 如果出问题了,可以使用下面命令查看:
systemctl status docker.service
通过ps -ef | grep docker可以查看刚才添加的信息:
[root@localhost ~]# ps -ef | grep docker
root 8262 1 0 23:50 ? 00:00:00 /usr/bin/docker daemon -H tcp://0.0.0.0:4243 -H unix:///var/run/docke
docker option
Usage of docker: --api-enable-cors=false Enable CORS headers in the remote API # 远程 API 中开启 CORS 头 -b, --bridge="" Attach containers to a pre-existing network bridge # 桥接网络 use 'none' to disable container networking --bip="" Use this CIDR notation address for the network bridge's IP, not compatible with -b # 和 -b 选项不兼容,具体没有测试过 -d, --daemon=false Enable daemon mode # daemon 模式 -D, --debug=false Enable debug mode # debug 模式 --dns=[] Force docker to use specific DNS servers # 强制 docker 使用指定 dns 服务器 --dns-search=[] Force Docker to use specific DNS search domains # 强制 docker 使用指定 dns 搜索域 -e, --exec-driver="native" Force the docker runtime to use a specific exec driver # 强制 docker 运行时使用指定执行驱动器 --fixed-cidr="" IPv4 subnet for fixed IPs (ex: 10.20.0.0/16) this subnet must be nested in the bridge subnet (which is defined by -b or --bip) -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 -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 # daemon 模式下 docker 指定绑定方式[tcp or 本地 socket] specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd. --icc=true Enable inter-container communication # 跨容器通信 --insecure-registry=[] Enable insecure communication with specified registries (no certificate verification for HTTPS and enable HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16) --ip="0.0.0.0" Default IP address to use when binding container ports # 指定监听地址,默认所有 ip --ip-forward=true Enable net.ipv4.ip_forward # 开启转发 --ip-masq=true Enable IP masquerading for bridge's IP range --iptables=true Enable Docker's addition of iptables rules # 添加对应 iptables 规则 --mtu=0 Set the containers network MTU # 设置网络 mtu if no value is provided: default to the default route MTU or 1500 if no default route is available -p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file # 指定 pid 文件位置 --registry-mirror=[] Specify a preferred Docker registry mirror -s, --storage-driver="" Force the docker runtime to use a specific storage driver # 强制 docker 运行时使用指定存储驱动 --selinux-enabled=false Enable selinux support # 开启 selinux 支持 --storage-opt=[] Set storage driver options # 设置存储驱动选项 --tls=false Use TLS; implied by tls-verify flags # 开启 tls --tlscacert="/root/.docker/ca.pem" Trust only remotes providing a certificate signed by the CA given here --tlscert="/root/.docker/cert.pem" Path to TLS certificate file # tls 证书文件位置 --tlskey="/root/.docker/key.pem" Path to TLS key file # tls key 文件位置 --tlsverify=false Use TLS and verify the remote (daemon: verify client, client: verify daemon) # 使用 tls 并确认远程控制主机 -v, --version=false Print version information and quit # 输出 docker 版本信息
0 0
- 2.1 docker 启动容器的时候可以使用的一些选项 和配置
- [docker]一些经常用到的docker容器启动方法
- docker容器的配置
- docker 配置可以运行spark的容器并运行
- 025-启动 docker 容器时,使用 -v 选项来挂载卷
- 修改无法启动的docker容器的配置
- docker容器的使用
- docker容器和Linux的一些指定,以便自己查阅
- Docker常用容器的使用
- Docker容器的基本使用
- win7下启动docker容器的访问地址和SSH连接docker虚拟环境的方法
- docker容器的多应用开机启动
- Docker删除所有启动的容器
- Docker容器的多应用开机启动
- 关于docker容器网络的一些理解
- docker 删除容器的时候出现的bug解决方案
- 使用 Docker 和 Fig 避免容器之间的竞争
- 由Docker的MySQL官方镜像配置的容器无法启动问题的解决办法
- shell脚本语言
- 1613-3-傅溥衍 总结《2016年12月3日》【连续第六十四天总结】
- 如何启用vim自带python自动补全功能
- socket实现最最最简单的http请求的数据
- 8.Ubuntu16.04构建docker镜像
- 2.1 docker 启动容器的时候可以使用的一些选项 和配置
- 栈的运用
- 9.Ubuntu16.04Docker的CS模式
- Qt实现两个非模态窗口的数据传递(信号与槽方式)
- 前馈神经网路的权值初始化方法
- 10.Ubuntu16.04守护进程的配置和操作
- C多线程练习题
- 字符设备和快设备的区别
- 数据结构实验之排序二:交换排序