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 is the function of daemon.json in Docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces what the role of daemon.json in Docker is. The content is very detailed. Interested friends can refer to it for reference. I hope it can help you.

After docker is installed, there is no daemon.json configuration file by default, which needs to be manually created. Default path of configuration file: /etc/docker/daemon. json

In general, the project parameters configured in the configuration file daemon.json are also applicable to the startup parameters, some of which may be different (see the official documentation for details). However, it should be noted that if there is already a configuration item in the configuration file, it cannot be added to the startup parameters, and a conflict error will occur.

{"api-cor-header":"","authorization-plugins":[],"bip": "","bridge":"","cgroup-parent":"","cluster-store":"","cluster-store-opts":{},"cluster-advertise":"","debug": true, #Enable debug mode. After enabling, you can see a lot of startup information. Default false"default-gateway":"","default-gateway-v6":"","default-runtime":"runc","default-ulimits":{},"disable-legacy-registry":false,"dns": ["192.168.1.1"], #Set the address of the container DNS, which can be viewed in the container's/etc/resolv.conf file. "dns-opts": [], #container/etc/resolv.conf file, other settings "dns-search": [], #Set the search domain of the container. When the search domain is set to. example.com, DNS searches not only host but also host.example.com when searching for a host named host. Note: If not set, Docker configures containers with/etc/resolv.conf on the host by default. "exec-opts":[],"exec-root":"","fixed-cidr":"","fixed-cidr-v6":"","graph":"/var/lib/docker", #deprecated, use data-root instead, this mainly depends on the docker version "data-root":"/var/lib/docker", #Root path Docker uses when running, content under root path will be described later, default/var/lib/docker"group": "", #Unix socket group, only/var/run/docker.sock"hosts": [], #Set container hosts"icc": false,"insecure-registries":[], #Configure docker's private repository address"ip":" 0.0.0.0","iptables": false,"ipv6": false," ip-forward": false, #default true, enable net.ipv4.ip_forward , use sysctl -a after entering container| grepnet.ipv4.ip_forward View "ip-masq":false,"labels":["nodeName=node-121"], # docker Host labels, very useful features, such as definition: -label nodeName=host-121 "live-restore": true,"log-driver":","log-level":","log-opts": {},"max-concurrent-downloads":3,"max-concurrent-uploads":5,"mtu": 0,"om-score-adjust":-500,"pidfile": "", #Docker daemon PID file "raw-logs": false,"registry-mirrors":["xxxx"], #Address of mirror acceleration, which can be viewed in docker info after adding. "runtimes":{"runc":{"path":"runc"},"custom":{"path":"/usr/local/bin/my-runc-replacement","runtimeArgs": ["--debug"]}},"selinux-enabled": false, #default false, enable selinux support "storage-driver":","storage-opts": [],"swarm-default-advertise-addr":","tls": true, #default false, enable TLS authentication switch "tlscacert": ", #default ~/.docker/ca.pem, path to certificate file certified by CA"tlscert":"", #default ~/.docker/cert.pem, TLS certificate file path "tlskey": "", #default ~/.docker/key.pem, TLS key file path "tlsverify": true, #default false, use TLS and do daemons to verify client communication "userland-proxy":false,"userns-remap":""}

The above is an example configuration provided by the official website docs. We can refer to some of the optional configurations.

example

1. How to configure parameters related to registry private library

The following two parameters are involved:

1

2

3

"insecure-registries": [], #Service address of this private repository

"registry-mirrors": [], #private library accelerator

2. Configuration example:

1

2

3

4

5

6

7

8

9

10

11

# cat /etc/docker/daemon.json

{

"registry-mirrors": [

"https://d8b3zdiw.mirror.aliyuncs.com"

],

"insecure-registries": [

"https://ower.site.com"

],

}

configuration and application

1. There is no file by default, so we need to create it first, enter the/etc/docker directory, remember to create the file owner is root (vim or touch, remember chown modify the owner)

-rw-r--r-- 1 root root 71 Dec 19 17:25daemon.json

2. Configure the parameters you want to add in the document: for example, Mirror Accelerator website, Private Library website

1

2

3

4

5

6

7

8

9

10

# cat /etc/docker/daemon.json

{

"registry-mirrors":[

"https://d8b3zdiw.mirror.aliyuncs.com"

],

"insecure-registries": [

"https://ower.site.com"

],

}

3. After creating and modifying the daemon.json file, you need to make it work.

a. Reload configuration file after modification

sudo systemctl daemon-reload

b. Restart docker service

sudo systemctl restart docker.service

c. View Status

sudo systemctl status docker -l

d. View Services

sudo docker info

When we need to adjust the configuration of docker service, we do not need to modify the parameters of the main file docker.service. It is safer and more reasonable to manage it through the daemon.json configuration file.

About the role of daemon.json in Docker is what to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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

Internet Technology

Wechat

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

12
Report