matterbridge 3.2.0-dev-20250801-e5ebd91 → 3.2.0-dev-20250802-fb1e4d0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,377 @@
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge development
2
+
3
+ [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
+ [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
5
+ [![Docker Version](https://img.shields.io/docker/v/luligu/matterbridge?label=docker%20version&sort=semver)](https://hub.docker.com/r/luligu/matterbridge)
6
+ [![Docker Pulls](https://img.shields.io/docker/pulls/luligu/matterbridge.svg)](https://hub.docker.com/r/luligu/matterbridge)
7
+ ![Node.js CI](https://github.com/Luligu/matterbridge/actions/workflows/build.yml/badge.svg)
8
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
10
+
11
+ [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
12
+ [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
13
+ [![power by](https://img.shields.io/badge/powered%20by-node--persist--manager-blue)](https://www.npmjs.com/package/node-persist-manager)
14
+
15
+ ---
16
+
17
+ # Development
18
+
19
+ ## How to create your plugin
20
+
21
+ The easiest way is to clone the [Matterbridge Plugin Template](https://github.com/Luligu/matterbridge-plugin-template) that has **Dev Container support for instant development environment** and all tools and extensions (like Node.js, npm, TypeScript, ESLint, Prettier, Jest and Vitest) already loaded and configured.
22
+
23
+ After you clone it locally, change the name (keep always matterbridge- at the beginning of the name), version, description, author, homepage, repository, bugs and funding in the package.json.
24
+
25
+ It is also possible to add two custom properties to the package.json: **help** and **changelog** with a url that will be used in the frontend instead of the default (/blob/main/README.md and /blob/main/CHANGELOG.md).
26
+
27
+ Add your plugin logic in module.ts.
28
+
29
+ The Matterbridge Plugin Template has an already configured Jest / Vitest test unit (with 100% coverage) that you can expand while you add your own plugin logic.
30
+
31
+ It also has a workflow configured to run on push and pull request that build, lint and test the plugin on node 20, 22 and 24 with ubuntu, macOS and windows.
32
+
33
+ ## Matterbridge Dev Container
34
+
35
+ Using a Dev Container provides a fully isolated, reproducible, and pre-configured development environment. This ensures that all contributors have the same tools, extensions, and dependencies, eliminating "works on my machine" issues. It also makes onboarding new developers fast and hassle-free, as everything needed is set up automatically.
36
+
37
+ For improved efficiency, the setup uses named Docker volumes for `node_modules`. This means dependencies are installed only once and persist across container rebuilds, making installs and rebuilds much faster than with bind mounts or ephemeral volumes.
38
+
39
+ To start the Dev Container, simply open the project folder in [Visual Studio Code](https://code.visualstudio.com/) and, if prompted, click "Reopen in Container". Alternatively, use the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`), search for "Dev Containers: Reopen in Container", and select it. VS Code will automatically build and start the containerized environment for you.
40
+
41
+ > **Note:** The first time you use the Dev Container, it may take a while to download all the required Docker images and set up the environment. Subsequent starts will be as as fast as from the local folder.
42
+
43
+ Since Dev Container doesn't run in network mode 'host', it is not possible to pair Mattebridge running inside the Dev Container.
44
+
45
+ ## Matterbridge Plugin Dev Container
46
+
47
+ Using a Dev Container provides a fully isolated, reproducible, and pre-configured development environment. This ensures that all contributors have the same tools, extensions, and dependencies, eliminating "works on my machine" issues. It also makes onboarding new developers fast and hassle-free, as everything needed is set up automatically.
48
+
49
+ For improved efficiency, the setup uses named Docker volumes for `matterbridge` and `node_modules`. This means that the dev of matterbridge and the plugin dependencies are installed only once and persist across container rebuilds, making installs and rebuilds much faster than with bind mounts or ephemeral volumes.
50
+
51
+ To start the Dev Container, simply open the project folder in [Visual Studio Code](https://code.visualstudio.com/) and, if prompted, click "Reopen in Container". Alternatively, use the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`), search for "Dev Containers: Reopen in Container", and select it. VS Code will automatically build and start the containerized environment for you.
52
+
53
+ > **Note:** The first time you use the Dev Container, it may take a while to download all the required Docker images and set up the environment. Subsequent starts will be as fast as from the local folder.
54
+
55
+ Since Dev Container doesn't run in network mode 'host', it is not possible to pair Mattebridge running inside the Dev Container.
56
+
57
+ ## Guidelines on imports/exports
58
+
59
+ Matterbridge exports from:
60
+
61
+ ### "matterbridge"
62
+
63
+ - Matterbridge and all Matterbridge related classes.
64
+
65
+ ### "matterbridge/devices"
66
+
67
+ - All single device classes like the Rvc, LaundryWasher, etc...
68
+
69
+ ### "matterbridge/clusters"
70
+
71
+ - All clusters not present in matter.js or modified.
72
+
73
+ ### "matterbridge/utils"
74
+
75
+ - All general utils and colorUtils functions.
76
+
77
+ ### "matterbridge/logger"
78
+
79
+ - AnsiLogger class.
80
+
81
+ ### "matterbridge/storage"
82
+
83
+ - NodeStorageManager and NodeStorage classes.
84
+
85
+ ### "matterbridge/matter"
86
+
87
+ - All relevant matter.js exports.
88
+
89
+ ### "matterbridge/matter/behaviors"
90
+
91
+ - All matter.js behaviors.
92
+
93
+ ### "matterbridge/matter/clusters"
94
+
95
+ - All matter.js clusters.
96
+
97
+ ### "matterbridge/matter/devices"
98
+
99
+ - All matter.js devices.
100
+
101
+ ### "matterbridge/matter/endpoints"
102
+
103
+ - All matter.js endpoints.
104
+
105
+ ### "matterbridge/matter/types"
106
+
107
+ - All matter.js types.
108
+
109
+ ### \***\*\*\*\*\*** WARNING \***\*\*\*\*\***
110
+
111
+ A plugin must never install or import from `@matter` or `@project-chip` directly (neither as a dependency, devDependency, nor peerDependency), as this leads to a second instance of `matter.js`, causing instability and unpredictable errors such as "The only instance is Endpoint".
112
+
113
+ Additionally, when Matterbridge updates the `matter.js` version, it should be consistent across all plugins.
114
+
115
+ ### \***\*\*\*\*\*** WARNING \***\*\*\*\*\***
116
+
117
+ A plugin must never install Matterbridge (neither as a dependency, devDependency, nor peerDependency).
118
+
119
+ Matterbridge must be linked to the plugin in development only. At runtime the plugin is loaded directly from the running Mattebridge instance.
120
+
121
+ ```json
122
+ "scripts": {
123
+ '''
124
+ "dev:link": "npm link matterbridge",
125
+ '''
126
+ }
127
+ ```
128
+
129
+ If you don't use Dev Container from the Matterbridge Plugin Template, on the host you use for the development of your plugin, you need to clone matterbridge, built it locally and link it globally (npm link from the matterbridge package root).
130
+
131
+ ```bash
132
+ git clone https://github.com/Luligu/matterbridge.git
133
+ cd matterbridge
134
+ npm install
135
+ npm run build
136
+ npm link
137
+ ```
138
+
139
+ If you want to develop a plugin using the dev branch of matterbridge (I suggest you do it).
140
+
141
+ ```bash
142
+ git clone -b dev https://github.com/Luligu/matterbridge.git
143
+ cd matterbridge
144
+ npm install
145
+ npm run build
146
+ npm link
147
+ ```
148
+
149
+ Always keep your local instance of matterbridge up to date.
150
+
151
+ ### WARNING \***\*\*\*\*\***
152
+
153
+ Some error messages are logged on start when a plugin has wrong imports or configurations and the plugin will be disabled to prevent instability and crashes.
154
+
155
+ ## How to install and register a plugin for development (from github)
156
+
157
+ To install i.e. https://github.com/Luligu/matterbridge-example-accessory-platform
158
+
159
+ On windows:
160
+
161
+ ```powershell
162
+ cd $HOME\Matterbridge
163
+ ```
164
+
165
+ On linux or macOS:
166
+
167
+ ```bash
168
+ cd ~/Matterbridge
169
+ ```
170
+
171
+ then clone the plugin
172
+
173
+ ```bash
174
+ git clone https://github.com/Luligu/matterbridge-example-accessory-platform
175
+ cd matterbridge-example-accessory-platform
176
+ npm install
177
+ npm link matterbridge
178
+ npm run build
179
+ ```
180
+
181
+ then add the plugin to Matterbridge
182
+
183
+ ```bash
184
+ matterbridge -add .
185
+ ```
186
+
187
+ ## MatterbridgeDynamicPlatform and MatterbridgeAccessoryPlatform api
188
+
189
+ ### public name: string
190
+
191
+ The plugin name.
192
+
193
+ ### public type: string
194
+
195
+ The plugin platform type.
196
+
197
+ ### public config: object
198
+
199
+ The plugin config (loaded before the platform constructor is called and saved after onShutdown() is called).
200
+ Here you can store your plugin configuration (see matterbridge-zigbee2mqtt for example)
201
+
202
+ ### constructor(matterbridge: Matterbridge, log: AnsiLogger, config: PlatformConfig)
203
+
204
+ The contructor is called when is plugin is loaded.
205
+
206
+ ### async onStart(reason?: string)
207
+
208
+ The method onStart() is where you have to create your MatterbridgeEndpoint and add all needed clusters.
209
+
210
+ After add the command handlers and subscribe to the attributes when needed.
211
+
212
+ The MatterbridgeEndpoint class has the create cluster methods already done and all command handlers needed (see plugin examples).
213
+
214
+ The method is called when Matterbridge load the plugin.
215
+
216
+ ### async onConfigure()
217
+
218
+ The method onConfigure() is where you can configure your matter device.
219
+
220
+ The method is called when the server node the platform belongs to is online.
221
+
222
+ Since the persistent attributes are loaded from the storage when the server node goes online, you may need to set them in onConfigure().
223
+
224
+ ### async onShutdown(reason?: string)
225
+
226
+ The method onShutdown() is where you have to stop your platform and cleanup all the used resources.
227
+
228
+ The method is called when Matterbridge is shutting down or when the plugin is disabled.
229
+
230
+ Since the frontend can enable and disable the plugin many times, you need to clean all resources (i.e. handlers, intervals, timers...) here.
231
+
232
+ ### async onChangeLoggerLevel(logLevel: LogLevel)
233
+
234
+ It is called when the user changes the logger level in the frontend.
235
+
236
+ ### async onAction(action: string, value?: string, id?: string, formData?: PlatformConfig)
237
+
238
+ It is called when a plugin config includes an action button or an action button with text field.
239
+
240
+ ### async onConfigChanged(config: PlatformConfig)
241
+
242
+ It is called when the plugin config has been updated.
243
+
244
+ ### getDevices(): MatterbridgeEndpoint[]
245
+
246
+ Retrieves the devices registered with the platform.
247
+
248
+ ### hasDeviceName(deviceName: string): boolean
249
+
250
+ Checks if a device with this name is already registered in the platform.
251
+
252
+ ### async registerDevice(device: MatterbridgeEndpoint)
253
+
254
+ After you have created your device, add it to the platform.
255
+
256
+ ### async unregisterDevice(device: MatterbridgeEndpoint)
257
+
258
+ You can unregister a device.
259
+
260
+ ### async unregisterAllDevices()
261
+
262
+ You can unregister all the devices you added.
263
+
264
+ It can be useful to call this method from onShutdown() if you don't want to keep all the devices during development.
265
+
266
+ ## MatterbridgeEndpoint api
267
+
268
+ You create a Matter device with a new instance of MatterbridgeEndpoint(definition: DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>, options: MatterbridgeEndpointOptions = {}, debug: boolean = false).
269
+
270
+ - @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint.
271
+ - @param {MatterbridgeEndpointOptions} [options] - The options for the device.
272
+ - @param {boolean} [debug] - Debug flag.
273
+
274
+ ```typescript
275
+ const device = new MatterbridgeEndpoint([contactSensor, powerSource], { id: 'EntryDoor' })
276
+ .createDefaultIdentifyClusterServer()
277
+ .createDefaultBasicInformationClusterServer('My entry door', '0123456789')
278
+ .createDefaultBooleanStateClusterServer(true)
279
+ .createDefaultPowerSourceReplaceableBatteryClusterServer(75)
280
+ .addRequiredClusterServers(); // Always better to call it at the end of the chain to add all the not already created but required clusters.
281
+ ```
282
+
283
+ In the above example we create a contact sensor device type with also a power source device type feature replaceble battery.
284
+
285
+ All device types are defined in src\matterbridgeDeviceTypes.ts and taken from the 'Matter-1.4-Device-Library-Specification.pdf'.
286
+
287
+ All default cluster helpers are available as methods of MatterbridgeEndpoint.
288
+
289
+ ## MatterbridgeEndpointOptions
290
+
291
+ ```typescript
292
+ const robot = new RoboticVacuumCleaner('Robot Vacuum', 'RVC1238777820', 'server');
293
+ ```
294
+
295
+ In the above example we create a Rvc device type with its own server node.
296
+
297
+ The mode=`server` property of MatterbridgeEndpointOptions, allows to create an independent (not bridged) Matter device with its server node. In this case the bridge mode is not relevant.
298
+
299
+ The mode=`matter` property of MatterbridgeEndpointOptions, allows to create a (not bridged) Matter device that is added to the Matterbridge server node alongside the aggregator.
300
+
301
+ ## Plugin config file
302
+
303
+ Each plugin has a minimal default config file injected by Matterbridge when it is loaded:
304
+
305
+ ```typescript
306
+ {
307
+ name: plugin.name, // i.e. matterbridge-test
308
+ type: plugin.type, // i.e. AccessoryPlatform or DynamicPlatform (on the first run is AnyPlatform cause it is still unknown)
309
+ debug: false,
310
+ unregisterOnShutdown: false
311
+ }
312
+ ```
313
+
314
+ It is possible to add a different default config file to be loaded the first time the user installs the plugin.
315
+
316
+ Matterbridge (only on the first load of the plugin and if a config file is not already present in the .matterbridge directory) looks for the default config file in the root of the plugin package. The file must be named '[PLUGIN-NAME].config.json' (i.e. 'matterbridge-test.config.json').
317
+
318
+ In all subsequent loads the config file is loaded from the '.matterbridge' directory.
319
+
320
+ ## Plugin schema file
321
+
322
+ Each plugin has a minimal default schema file injected by Matterbridge when it is loaded:
323
+
324
+ ```typescript
325
+ {
326
+ title: plugin.description,
327
+ description: plugin.name + ' v. ' + plugin.version + ' by ' + plugin.author,
328
+ type: 'object',
329
+ properties: {
330
+ name: {
331
+ description: 'Plugin name',
332
+ type: 'string',
333
+ readOnly: true,
334
+ },
335
+ type: {
336
+ description: 'Plugin type',
337
+ type: 'string',
338
+ readOnly: true,
339
+ },
340
+ debug: {
341
+ description: 'Enable the debug for the plugin (development only)',
342
+ type: 'boolean',
343
+ default: false,
344
+ },
345
+ unregisterOnShutdown: {
346
+ description: 'Unregister all devices on shutdown (development only)',
347
+ type: 'boolean',
348
+ default: false,
349
+ },
350
+ },
351
+ }
352
+ ```
353
+
354
+ It is possible to add a different default schema file.
355
+
356
+ The schema file is loaded from the root of the plugin package. The file must be named '[PLUGIN-NAME].schema.json' (i.e. 'matterbridge-test.schema.json').
357
+
358
+ The properties of the schema file shall correspond to the properties of the config file.
359
+
360
+ # Contribution Guidelines
361
+
362
+ Thank you for your interest in contributing to my project!
363
+
364
+ I warmly welcome contributions to this project! Whether it's reporting bugs, proposing new features, updating documentation, or writing code, your help is greatly appreciated.
365
+
366
+ ## Getting Started
367
+
368
+ - Fork this repository to your own GitHub account and clone it to your local device.
369
+ - Make the necessary changes and test them out
370
+ - Commit your changes and push to your forked repository
371
+
372
+ ## Submitting Changes
373
+
374
+ - Create a new pull request against the dev from my repository and I'll be glad to check it out
375
+ - Be sure to follow the existing code style
376
+ - Add unit tests for any new or changed functionality if possible
377
+ - In your pull request, do describe what your changes do and how they work
@@ -0,0 +1,208 @@
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge docker configuration
2
+
3
+ [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
+ [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
5
+ [![Docker Version](https://img.shields.io/docker/v/luligu/matterbridge?label=docker%20version&sort=semver)](https://hub.docker.com/r/luligu/matterbridge)
6
+ [![Docker Pulls](https://img.shields.io/docker/pulls/luligu/matterbridge.svg)](https://hub.docker.com/r/luligu/matterbridge)
7
+ ![Node.js CI](https://github.com/Luligu/matterbridge/actions/workflows/build.yml/badge.svg)
8
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
10
+
11
+ [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
12
+ [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
13
+ [![power by](https://img.shields.io/badge/powered%20by-node--persist--manager-blue)](https://www.npmjs.com/package/node-persist-manager)
14
+
15
+ ---
16
+
17
+ # Advanced configuration
18
+
19
+ ## Run matterbridge with docker and docker compose
20
+
21
+ The Matterbridge Docker image, which includes a manifest list for the linux/amd64, linux/arm64 and linux/arm/v7 architectures, is published on **Docker Hub**.
22
+
23
+ The image (tag **latest**) includes matterbridge and all official plugins with the latest release (as published on npm). You can just pull the new image and matterbridge with all plugins will be the latest release published on npm.
24
+
25
+ The image (tag **dev**) includes matterbridge and all plugins with the dev release (as pushed on GitHub). You can just pull the new image and matterbridge with all plugins will be the latest dev release pushed on GitHub. It is possible that the devs are outdated by published latests.
26
+
27
+ You can directly select and add a plugin without installing it.
28
+
29
+ It is based on node:22-bookworm-slim and integrates the health check.
30
+
31
+ How Health Checks Work in Different Scenarios
32
+
33
+ With docker-compose
34
+
35
+ Docker monitors the health check and can restart the container if needed.
36
+
37
+ With docker run
38
+
39
+ The health check still runs in the background, but:
40
+ The container doesn’t restart automatically if it becomes unhealthy.
41
+
42
+ You can manually check the health status:
43
+
44
+ ```bash
45
+ docker exec -it matterbridge curl -v http://localhost:8283/health
46
+ ```
47
+
48
+ ### First create the Matterbridge directories
49
+
50
+ This will create the required directories in your home directory if they don't exist
51
+
52
+ ```bash
53
+ cd ~
54
+ mkdir -p ~/Matterbridge
55
+ mkdir -p ~/.matterbridge
56
+ sudo chown -R $USER:$USER ~/Matterbridge ~/.matterbridge
57
+ ```
58
+
59
+ You may need to adapt the script to your setup.
60
+
61
+ ### Add your user to docker group
62
+
63
+ If you don't want to use sudo with docker commands, run this command:
64
+
65
+ ```bash
66
+ sudo groupadd docker
67
+ sudo usermod -aG docker $USER
68
+ ```
69
+
70
+ After adding your user to the docker group, you need to log out and log back in for the changes to take effect. This ensures that your current session recognizes the group membership change.
71
+
72
+ ### Run the Docker container and start it
73
+
74
+ The container must have full access to the host network (needed for mdns and Matter protocol).
75
+
76
+ ```bash
77
+ sudo docker run --name matterbridge \
78
+ -v ~/Matterbridge:/root/Matterbridge \
79
+ -v ~/.matterbridge:/root/.matterbridge \
80
+ --network host --restart always -d luligu/matterbridge:latest
81
+ ```
82
+
83
+ You may need to adapt the script to your setup.
84
+
85
+ ### Run with docker compose
86
+
87
+ The docker-compose.yml file is available in the docker directory of the package
88
+
89
+ ```
90
+ services:
91
+ matterbridge:
92
+ container_name: matterbridge
93
+ image: luligu/matterbridge:latest # Matterbridge image with the tag latest
94
+ network_mode: host # Ensures the Matter mdns works
95
+ restart: always # Ensures the container always restarts automatically
96
+ volumes:
97
+ - "${HOME}/Matterbridge:/root/Matterbridge" # Mounts the Matterbridge plugin directory
98
+ - "${HOME}/.matterbridge:/root/.matterbridge" # Mounts the Matterbridge storage directory
99
+ ```
100
+
101
+ Copy it in the home directory or edit the existing one to add the matterbridge service.
102
+
103
+ Then start docker compose with:
104
+
105
+ ```bash
106
+ docker compose up -d
107
+ ```
108
+
109
+ or start only the matterbridge container with:
110
+
111
+ ```bash
112
+ docker compose up -d matterbridge
113
+ ```
114
+
115
+ ### Stop with docker compose
116
+
117
+ ```bash
118
+ docker compose down
119
+ ```
120
+
121
+ ### Update with docker compose
122
+
123
+ This will pull the new matterbridge image and restart only the matterbridge container.
124
+
125
+ ```bash
126
+ docker compose pull matterbridge
127
+ docker compose up -d --no-deps --force-recreate matterbridge
128
+ ```
129
+
130
+ ### Inspect the container
131
+
132
+ ```bash
133
+ docker container inspect matterbridge
134
+ ```
135
+
136
+ ### Start the Docker container
137
+
138
+ ```bash
139
+ docker start matterbridge
140
+ ```
141
+
142
+ ### Stop the Docker container
143
+
144
+ ```bash
145
+ docker stop matterbridge
146
+ ```
147
+
148
+ ### Restart the Docker container
149
+
150
+ ```bash
151
+ docker restart matterbridge
152
+ ```
153
+
154
+ ### Shows the logs
155
+
156
+ ```bash
157
+ docker logs matterbridge
158
+ ```
159
+
160
+ ### Shows the logs for a time interval
161
+
162
+ ```bash
163
+ docker logs \
164
+ --since "2025-04-19T00:00:00" \
165
+ --until "2025-04-19T00:02:00" \
166
+ matterbridge
167
+ ```
168
+
169
+ ### Shows the logs real time (tail)
170
+
171
+ ```bash
172
+ docker logs --tail 1000 -f matterbridge
173
+ ```
174
+
175
+ ### Prevent the logs to grow
176
+
177
+ If you want to prevent the docker logs to grow too much, you can configure Docker's logging options globally.
178
+
179
+ **Warning**: This will restart Docker and affect all running containers.
180
+
181
+ ```bash
182
+ sudo nano /etc/docker/daemon.json
183
+ ```
184
+
185
+ Add or update the logging configuration in the daemon.json file:
186
+
187
+ ```json
188
+ {
189
+ "log-driver": "json-file",
190
+ "log-opts": {
191
+ "max-size": "100m",
192
+ "max-file": "3"
193
+ }
194
+ }
195
+ ```
196
+
197
+ Where:
198
+
199
+ - `max-size`: Maximum size of each log file (e.g., "10m", "100m", "1g")
200
+ - `max-file`: Maximum number of log files to keep
201
+
202
+ Save the file and restart Docker:
203
+
204
+ ```bash
205
+ sudo systemctl restart docker
206
+ ```
207
+
208
+ **Note**: This configuration applies to new containers. Existing containers will need to be recreated to use the new logging settings.