Skip to content

Commit 16c4fbc

Browse files
author
mengxiancheng
committed
fix: create correct Docker Registry V2 directory structure
Signed-off-by: mengxiancheng <[email protected]>
1 parent ffd7149 commit 16c4fbc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/storage/distribution/distribution.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24+
"os"
25+
"path/filepath"
2426
"regexp"
2527
"time"
2628

@@ -61,6 +63,24 @@ func NewStorage(rootDir string) (*storage, error) {
6163
// Mute the logging from distribution.
6264
logrus.SetOutput(io.Discard)
6365

66+
// Create Docker Registry V2 directory structure
67+
dockerRegistryDir := filepath.Join(rootDir, "docker", "registry")
68+
if err := os.MkdirAll(dockerRegistryDir, 0755); err != nil {
69+
return nil, fmt.Errorf("failed to create docker registry directory: %w", err)
70+
}
71+
72+
// Create v2 directory
73+
v2Dir := filepath.Join(dockerRegistryDir, "v2")
74+
if err := os.MkdirAll(v2Dir, 0755); err != nil {
75+
return nil, fmt.Errorf("failed to create v2 directory: %w", err)
76+
}
77+
78+
// Create repositories directory under v2
79+
repositoriesDir := filepath.Join(v2Dir, "repositories")
80+
if err := os.MkdirAll(repositoriesDir, 0755); err != nil {
81+
return nil, fmt.Errorf("failed to create repositories directory: %w", err)
82+
}
83+
6484
fsDriver := filesystem.New(filesystem.DriverParameters{
6585
RootDirectory: rootDir,
6686
MaxThreads: defaultMaxThreads,

0 commit comments

Comments
 (0)