# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d
other_args="-b br0"
接着使用service docker start启动docker服务,但是other_args并不生效,在centos7下servicer docker start仍然会采用systemctl start docker.service命令来运行,于是我就打开/usr/lib/systemd/system/docker.service查看
[root@test opt]# vi /lib/systemd/system/docker.service
[Unit]Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket
[Service]ExecStart=/usr/bin/docker -d -H fd://
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity [Install]WantedBy=multi-user.target
发现ExecStart一项并没有运行参数,于是将ExecStart改为/usr/bin/docker -d -b br0 -H fd://,运行docker服务,启动一个容器发现能够成功使用br0网桥。
在网上看到了一种更好的方法,将docker.service改为如下
[black@test ~]$ vi /usr/lib/systemd/system/docker.service
[Unit]Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket
[Service]EnvironmentFile=-/etc/sysconfig/docker
ExecStart=/usr/bin/docker -d $other_args -H fd://
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity [Install]WantedBy=multi-user.target 这个时候在other_args中添加的参数就有效了。
您可能感兴趣的文章:详解如何修改 Docker 默认网桥地址Docker如何使用OpenvSwitch网桥Docker使用自定义网桥详解修改docker启动默认网桥docker0为自定义网桥










