Skip to content

Commit a0b56e7

Browse files
committed
fix: exclude system volumes from a clone container
1 parent 1fea01a commit a0b56e7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/services/provision/docker/docker.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const (
2626
labelClone = "dblab_clone"
2727
)
2828

29+
var systemVolumes = []string{"/sys", "/lib", "/proc"}
30+
2931
// RunContainer runs specified container.
3032
func RunContainer(r runners.Runner, c *resources.AppConfig) (string, error) {
3133
hostInfo, err := host.Info()
@@ -94,6 +96,11 @@ func buildMountVolumes(r runners.Runner, c *resources.AppConfig, containerID str
9496
volumes := make([]string, 0, len(mounts))
9597

9698
for _, mountPoint := range mountPoints {
99+
// Exclude system volumes from a clone container.
100+
if isSystemVolume(mountPoint.Source) {
101+
continue
102+
}
103+
97104
// Add extra mount for socket directories.
98105
if strings.HasPrefix(unixSocketCloneDir, mountPoint.Destination) {
99106
volumes = append(volumes, buildSocketMount(unixSocketCloneDir, mountPoint.Source, mountPoint.Destination))
@@ -114,6 +121,16 @@ func buildMountVolumes(r runners.Runner, c *resources.AppConfig, containerID str
114121
return volumes, nil
115122
}
116123

124+
func isSystemVolume(source string) bool {
125+
for _, sysVolume := range systemVolumes {
126+
if strings.HasPrefix(source, sysVolume) {
127+
return true
128+
}
129+
}
130+
131+
return false
132+
}
133+
117134
// buildSocketMount builds a socket directory mounting rely on dataDir mounting.
118135
func buildSocketMount(socketDir, hostDataDir, destinationDir string) string {
119136
socketPath := strings.TrimPrefix(socketDir, destinationDir)

0 commit comments

Comments
 (0)