Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the DOCKER_OPTS parameter in / etc/default/docker modified in Docker does not take effect?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you what to do if the DOCKER_OPTS parameter in / etc/default/docker does not take effect in Docker. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

By default, the / etc/default/docker configuration will not take effect, and we need to manually add it to the environment settings of docker. The file we need to configure is / usr/lib/systemd/system/docker.service, and we need to add EnvironmentFile=-/etc/default/docker, so that in the configuration of ExecStart, add the referenced parameter $DOCKER_OPTS.

Docker.service

When configuring docker.service, the file of EnvironmentFile is configured with / etc/sysconfig/docker (basic configuration), / etc/sysconfig/docker-storage (storage), / etc/sysconfig/docker-network (network) by default. If we want / etc/default/docker to take effect, we need to add EnvironmentFile=-/etc/default/docker so that we can add the referenced parameter $DOCKER_OPTS in the configuration of ExecStart. Here is my configuration file / usr/lib/systemd/system/docker.service.

# modify configuration file vi / usr/lib/systemd/system/ docker.service [unit] Description=Docker Application Container EngineDocumentation= http://docs.docker.comAfter=network.targetWants=docker-storage-setup.serviceRequires=docker-cleanup.timer[Service]Type=notifyNotifyAccess=allKillMode=process# add our custom configuration file EnvironmentFile=-/etc/default/docker # add configuration file (- for ignore error) EnvironmentFile=-/etc/sysconfig/dockerEnvironmentFile=-/etc/sysconfig/docker-storageEnvironmentFile=-/etc/sysconfig/docker-networkEnvironment=GOTRACEBACK=crashEnvironment=DOCKER_HTTP_HOST_COMPAT=1Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbinExecStart=/usr/bin/dockerd-current\-add-runtime docker-runc=/usr/libexec/docker/docker-runc-current\-default-runtime=docker-runc\-exec-opt native.cgroupdriver=systemd\-userland-proxy- Path=/usr/libexec/docker/docker-proxy-current\ $OPTIONS\ $DOCKER_STORAGE_OPTIONS\ $DOCKER_NETWORK_OPTIONS\ $ADD_REGISTRY\ $BLOCK_REGISTRY\ $INSECURE_REGISTRY\ $DOCKER_OPTS # parameters to be referenced It is also the setting parameter of the network card ExecReload=/bin/kill-s HUP $MAINPIDLimitNOFILE=1048576LimitNPROC=1048576LimitCORE=infinityTimeoutStartSec=0Restart=on-abnormalMountFlags=slave [Install] WantedBy=multi-user.targetEnvironmentFile=-/etc/default/docker

After modification, you need to reload and restart the service before you can use the DOCKER_OPTS parameter defined in / etc/default/docker

# reload systemctl daemon-reload# and restart docker service service docker restart

Docker environment profile

Vi / etc/sysconfig/dockerDOCKER_OPTS= "- b=br0" # or write data echo 'DOCKER_OPTS= "- b=br0" > / etc/default/docker directly

Docker Custom Bridge

# install bridge tool yum install bridge-utils # add bridge brctl addbr br0# view bridge brctl show # set bridge address and subnet mask ifconfig br0 192.168.110.1 netmask 255.255.255." set bridge echo 'DOCKER_OPTS= "- b=br0" > > / etc/default/docker# configuration dockervi / usr/lib/systemd/system/docker.service# add our own profile EnvironmentFile=-/etc/sysconfig/docker# application parameter ExecStart= / usr/bin/dockerd-current\-add-runtime docker-runc=/usr/libexec/docker/docker-runc-current\-default-runtime=docker-runc\-exec-opt native.cgroupdriver=systemd\-userland-proxy-path=/usr/libexec/docker/docker-proxy-current\ $OPTIONS\ $DOCKER_STORAGE_OPTIONS\ $DOCKER_NETWORK_OPTIONS\ $ADD_REGISTRY\ $BLOCK_REGISTRY\ $INSECURE_REGISTRY\ $DOCKER_OPTS # add parameters for bridge # reload systemctl daemon-reload# restart docker service service docker restart

Bridge information after successful modification

View bridge data

After the bridge is modified successfully, the network segment and subnet mask of the network card are modified.

Thank you for reading! This is the end of the article on "what if the DOCKER_OPTS parameters in Docker / etc/default/docker do not take effect". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report