You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduces immutability to IPP-USB OCI image (#106)
* Introduce immutability to IPP-USB OCI image
* Update README to include runtime flags for data persistence
* Update documentation for configuration and logging setup
* Include nano in Rock image and improve docs with persistent storage for ipp-usb
* Enhance persistence: Separate volumes for state, config, and logs in ipp-usb.
#### **3. Run the Container with Required Mounts**
268
+
Start the container with appropriate options:
260
269
261
-
To check the logs of `ipp-usb`, run:
262
270
```sh
263
-
sudo docker logs -f ipp-usb
271
+
sudo docker run -d --network host \
272
+
-v /dev/bus/usb:/dev/bus/usb:ro \
273
+
-v ipp-usb-state:/var/ipp-usb \
274
+
-v ipp-usb-conf:/etc/ipp-usb \
275
+
--device-cgroup-rule='c 189:* rmw' \
276
+
--name ipp-usb \
277
+
ghcr.io/openprinting/ipp-usb:latest
264
278
```
265
279
280
+
-**`--network host`** → Uses the host’s network to enable proper IPP-over-USB and Avahi service discovery.
281
+
-**`-v /dev/bus/usb:/dev/bus/usb:ro`** → Grants read-only access to USB devices for printer detection.
282
+
-**`-v ipp-usb-state:/var/ipp-usb`** → Mounts the persistent storage volume for printer state, lock files, and logs.
283
+
-**`-v ipp-usb-conf:/etc/ipp-usb`** → Ensures configuration and quirks files persist across reboots.
284
+
-**`--device-cgroup-rule='c 189:* rmw'`** → Grants read, write, and management permissions for USB printers inside the container.
285
+
286
+
266
287
### Building and Running `ipp-usb` Locally
267
288
268
289
#### Prerequisites
269
290
270
-
**Docker Installed**: Ensure Docker is installed on your system. You can download it from the [official Docker website](https://www.docker.com/get-started) or from the Snap Store:
291
+
1.**Docker Installed**: Ensure Docker is installed on your system. You can download it from the [official Docker website](https://www.docker.com/get-started) or from the Snap Store:
271
292
```sh
272
293
sudo snap install docker
273
294
```
274
295
275
-
**Rockcraft**: Rockcraft should be installed. You can install Rockcraft using the following command:
296
+
2.**Rockcraft**: Rockcraft should be installed. You can install Rockcraft using the following command:
276
297
```sh
277
298
sudo snap install rockcraft --classic
278
299
```
279
300
280
-
#### Step-by-Step Guide
281
-
282
-
**Build the `ipp-usb` Rock Image**
301
+
**To Build and Run the `ipp-usb` Rock Image Locally, follow these steps**
283
302
284
-
The first step is to build the Rock from the `rockcraft.yaml`. This image will contain all the configurations and dependencies required to run `ipp-usb`.
303
+
#### **1. Build the `ipp-usb` Rock Image**
304
+
The first step is to build the Rock image from the `rockcraft.yaml` configuration file. This image will include all required dependencies and configurations for `ipp-usb`.
285
305
286
-
Navigate to the directory containing `rockcraft.yaml`, then run:
306
+
Navigate to the directory containing `rockcraft.yaml` and run:
287
307
```sh
288
308
rockcraft pack -v
289
-
```
309
+
```
290
310
291
-
**Compile to Docker Image**
311
+
#### **2. Convert the Rock Image to a Docker Image**
312
+
Once the `.rock` file is built, convert it into a Docker image using:
- Press `CTRL + X`, then `Y`, and hit `Enter` to save the changes.
388
+
389
+
#### **4. Restart the Container to Apply Changes**
390
+
Exit the container and restart it to apply the updated configuration:
391
+
```sh
392
+
sudo docker restart ipp-usb
393
+
```
394
+
395
+
### **Viewing Logs in the `ipp-usb` Container**
396
+
397
+
The `ipp-usb` container logs important events and errors to `/var/log/ipp-usb/`. Logs are categorized into:
398
+
399
+
-**Main log file:**`/var/log/ipp-usb/main.log` → Captures overall service activity, including errors and general events.
400
+
-**Per-device logs:**`/var/log/ipp-usb/<DEVICE>.log` → Individual log files for each detected printer, helpful for troubleshooting device-specific issues.
401
+
402
+
#### **1. Using Docker Logs**
403
+
404
+
To view real-time logs from the running container, use:
405
+
```sh
406
+
sudo docker logs -f ipp-usb
407
+
```
408
+
- The `-f` flag follows the logs in real-time.
409
+
- Replace `ipp-usb` with your actual container name if different.
410
+
411
+
#### **2. Viewing Logs Inside the Container**
412
+
413
+
If you need to inspect logs manually, first enter the container shell:
414
+
```sh
415
+
sudo docker exec -it ipp-usb bash
416
+
```
417
+
418
+
Once inside the container, you can use the following commands:
419
+
420
+
#### **2.1 Monitor Logs in Real-Time**
421
+
422
+
-**Main log file:**
423
+
```sh
424
+
tail -f /var/log/ipp-usb/main.log
425
+
```
426
+
This continuously displays new log entries for the entire service.
427
+
428
+
-**Per-device log file (Replace `<DEVICE>` with your printer's identifier):**
429
+
```sh
430
+
tail -f /var/log/ipp-usb/<DEVICE>.log
431
+
```
432
+
433
+
#### **2.2 Display Full Log Files**
434
+
435
+
-**Show full contents of the main log file:**
436
+
```sh
437
+
cat /var/log/ipp-usb/main.log
438
+
```
439
+
440
+
-**Show logs for a specific device:**
441
+
```sh
442
+
cat /var/log/ipp-usb/<DEVICE>.log
443
+
```
444
+
445
+
#### **2.3 List Available Device Logs**
446
+
447
+
To see all available per-device log files, run:
448
+
```sh
449
+
ls /var/log/ipp-usb/
450
+
```
451
+
452
+
#### **3. Persisting Logs Across Container Restarts**
453
+
454
+
If you want logs to persist across container restarts, you should mount the log directory using a Docker volume or a host directory.
455
+
456
+
**Required Docker Flags for Log Persistence:**
457
+
-`-v <volume-name>:/var/log/ipp-usb` → Mounts a Docker volume for log persistence.
458
+
-**or**
459
+
-`-v <host-directory>:/var/log/ipp-usb` → Mounts a host directory to retain logs outside the container.
460
+
461
+
These options ensure that logs remain available even after the container stops or is recreated, allowing for easier troubleshooting and auditing.
0 commit comments