Commit 8b8786c
authored
Create parent directories for Windows container image (#313)
Most container runtimes, including containerd and Moby (aka Docker) with Linux images
will accept tar files where directory entries are missing.
```
-rwxr-xr-x 0/0 117 1970-01-01 01:00 app/bb_storage.repo_mapping
-rwxr-xr-x 0/0 49701048 1970-01-01 01:00 app/bb_storage
hrwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.runfiles/_repo_mapping link to app/bb_storage.repo_mapping
hrwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.runfiles/_main/cmd/bb_storage/bb_storage_/bb_storage link to app/bb_storage
```
If a file like `app/bb_storage.repo_mapping` is extracted, any missing parent directories are created during extraction (but before the file is created): https://github.com/containerd/containerd/blob/dea7da592f5d1d2b7755e3a161be07f43fad8f75/pkg/archive/tar.go#L268-L276
On Windows (at least with Moby), missing parent directories are never created: https://github.com/microsoft/hcsshim/blob/d97b376c86e77d0df1b94500350fd2625c516dbf/internal/wclayer/legacy.go#L694
For that reason we explicitly create those directories on Windows:
```
drwxr-xr-x 0/0 0 1970-01-01 01:00 app/
-rwxr-xr-x 0/0 117 1970-01-01 01:00 app/bb_storage.exe.repo_mapping
-rwxr-xr-x 0/0 50391552 1970-01-01 01:00 app/bb_storage.exe
drwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.exe.runfiles/
hrwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.exe.runfiles/_repo_mapping link to app/bb_storage.exe.repo_mapping
drwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.exe.runfiles/_main/
drwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.exe.runfiles/_main/cmd/
drwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.exe.runfiles/_main/cmd/bb_storage/
drwxr-xr-x 0/0 0 1970-01-01 01:00 app/bb_storage.exe.runfiles/_main/cmd/bb_storage/bb_storage_/
hrwxr-xr-x 0/0 0 1970-01-01 01:00
app/bb_storage.exe.runfiles/_main/cmd/bb_storage/bb_storage_/bb_storage.exe
link to app/bb_storage.extracted
```
Note that it is generally better NOT to create parent directories, since any directories created in upper layers (like `/app` here) shadow potential directory contents of lower layers.
Long term, we should probably fix tar extraction on Windows upstream.1 parent 33893b3 commit 8b8786c
1 file changed
+8
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
| |||
0 commit comments