Skip to content

Commit 8b909f3

Browse files
committed
Updated README
1 parent 712f840 commit 8b909f3

File tree

1 file changed

+115
-8
lines changed

1 file changed

+115
-8
lines changed

README.md

Lines changed: 115 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
A command-line tool to inspect the contents of Docker images without having to manually create containers or extract tar files. The tool creates a temporary container, inspects its filesystem, and cleans up automatically.
44

5+
## Beware: Experimental (WIP)
6+
7+
This is work in progress and not finished or bug free. In fact there are known problems and everything was only tested on osx so far.
8+
59
## Features
610

711
- Cross-platform: Runs on macOS, Linux, and Windows (with Linux containers)
812
- Inspects any Docker image without modifying it
13+
- Extracts files from images to local filesystem
914
- Recursive directory listing
1015
- Glob pattern support (including `**/`) for finding specific files
1116
- MD5 checksum calculation for files
@@ -33,7 +38,11 @@ make windows
3338

3439
Basic usage:
3540
```bash
41+
# Inspect a single image
3642
./docker-inspector nginx:latest
43+
44+
# Compare two images
45+
./docker-inspector nginx:latest nginx:1.24
3746
```
3847

3948
With options:
@@ -52,7 +61,96 @@ With options:
5261

5362
# Keep container for further inspection
5463
./docker-inspector nginx:latest --keep
64+
65+
# Extract files from image
66+
./docker-inspector nginx:latest --output-dir ./extracted --glob "**/*.conf"
67+
68+
# Extract with preserved permissions and ownership
69+
./docker-inspector nginx:latest --output-dir ./extracted --preserve-all
70+
71+
# Extract stripping leading path components
72+
./docker-inspector nginx:latest --output-dir ./extracted --glob "/etc/nginx/**" --strip-components 2
73+
```
74+
75+
### Image Comparison Mode
76+
77+
When two images are specified, the tool operates in comparison mode, showing the differences between them:
78+
79+
```bash
80+
# Compare two different versions
81+
./docker-inspector nginx:latest nginx:1.24
82+
83+
# Compare with content verification
84+
./docker-inspector nginx:latest nginx:1.24 --md5
85+
86+
# Focus on specific files
87+
./docker-inspector nginx:latest nginx:1.24 --glob "**/*.conf"
88+
89+
# Compare without modification times
90+
./docker-inspector nginx:latest nginx:1.24 --no-times
91+
92+
# Get machine-readable diff
93+
./docker-inspector nginx:latest nginx:1.24 --json
94+
```
95+
96+
The comparison shows:
97+
- Added files (present in second image but not in first)
98+
- Removed files (present in first image but not in second)
99+
- Modified files with details about what changed:
100+
- Size differences
101+
- Permission changes
102+
- Ownership changes
103+
- Content changes (when --md5 is used)
104+
- Modification time changes (unless --no-times is specified)
105+
106+
Example output:
55107
```
108+
Comparison Summary:
109+
Total differences: 5
110+
Added files: 2
111+
Removed files: 1
112+
Modified files: 2
113+
114+
Details:
115+
+ /etc/nginx/new-feature.conf
116+
(1234 bytes, nginx:nginx, mode -rw-r--r--)
117+
- /etc/nginx/deprecated.conf
118+
(890 bytes, root:root, mode -rw-r--r--)
119+
M /etc/nginx/nginx.conf
120+
size changed: 1500 -> 1600
121+
content changed (different MD5)
122+
M /etc/nginx/conf.d/default.conf
123+
permissions changed: -rw-r--r-- -> -rw-r--r--
124+
```
125+
126+
The tool exits with:
127+
- Status 0 if no differences are found
128+
- Status 1 if differences are found or an error occurs
129+
130+
This is useful for:
131+
- Validating image updates
132+
- Auditing configuration changes
133+
- Checking for unwanted modifications
134+
- Automation and CI/CD pipelines
135+
136+
137+
### File Extraction Options
138+
139+
The tool can extract files from Docker images to your local filesystem:
140+
141+
- `--output-dir <path>`: Extract matching files to this directory
142+
- `--preserve-permissions`: Preserve file permissions when extracting
143+
- `--preserve-user`: Preserve user/group ownership when extracting (requires root/sudo)
144+
- `--preserve-all`: Preserve all file attributes (equivalent to both above)
145+
- `--strip-components N`: Strip N leading components from file names when extracting
146+
147+
For example, with `--strip-components 2`, a file path `/etc/nginx/nginx.conf` becomes `nginx.conf` in the output directory.
148+
149+
Note: When preserving ownership on macOS:
150+
- Docker Desktop's implementation limits ownership preservation through bind mounts
151+
- The destination filesystem must support Unix ownership attributes
152+
- The tool will automatically use sudo to fix ownership after the copy
153+
- Some macOS volumes (like external drives) might not support ownership changes
56154

57155
### Comparing Images
58156

@@ -75,13 +173,18 @@ Note: Files like /etc/resolv.conf typically show modification time differences b
75173
### Options
76174

77175
```
78-
--path Path inside the container to inspect (default: "/")
79-
--json Output in JSON format
80-
--summary Show summary statistics
81-
--glob Glob pattern for matching files (supports **/)
82-
--md5 Calculate MD5 checksums for files
83-
--keep Keep the temporary container after inspection
84-
--no-times Exclude modification times from output (useful for diffs)
176+
--path Path inside the container to inspect (default: "/")
177+
--json Output in JSON format
178+
--summary Show summary statistics
179+
--glob Glob pattern for matching files (supports **/)
180+
--md5 Calculate MD5 checksums for files
181+
--keep Keep the temporary container after inspection
182+
--no-times Exclude modification times from output (useful for diffs)
183+
--output-dir Extract matching files to this directory
184+
--strip-components Strip NUMBER leading components from file names when extracting
185+
--preserve-perms Preserve file permissions when extracting
186+
--preserve-owner Preserve user/group ownership when extracting
187+
--preserve-all Preserve all file attributes
85188
```
86189

87190
## How It Works
@@ -91,7 +194,11 @@ The tool:
91194
2. Copies a specialized Linux inspector binary into the container
92195
3. Executes the inspector inside the container
93196
4. Collects and formats the results
94-
5. Automatically cleans up the container (unless --keep is specified)
197+
5. When extracting files:
198+
- Mounts the output directory into the container
199+
- Copies files with requested attributes preserved
200+
- On macOS, uses sudo to fix ownership if requested
201+
6. Automatically cleans up the container (unless --keep is specified)
95202

96203
## Building from Source
97204

0 commit comments

Comments
 (0)