diff --git a/playground/local_runner.go b/playground/local_runner.go index 863c8e9..6c38221 100644 --- a/playground/local_runner.go +++ b/playground/local_runner.go @@ -648,11 +648,16 @@ func (d *LocalRunner) toDockerComposeService(s *Service) (map[string]interface{} // create the bind volumes for localPath, volumeName := range s.VolumesMapped { - volumeDirAbsPath, err := d.createVolume(s.Name, volumeName) - if err != nil { - return nil, err + // If the volume name is an absolute path, use it directly + if filepath.IsAbs(volumeName) { + volumes[volumeName] = localPath + } else { + volumeDirAbsPath, err := d.createVolume(s.Name, volumeName) + if err != nil { + return nil, err + } + volumes[volumeDirAbsPath] = localPath } - volumes[volumeDirAbsPath] = localPath } volumesInLine := []string{} @@ -671,6 +676,10 @@ func (d *LocalRunner) toDockerComposeService(s *Service) (map[string]interface{} "labels": labels, } + if s.Privileged { + service["privileged"] = true + } + if d.platform != "" { service["platform"] = d.platform } diff --git a/playground/manifest.go b/playground/manifest.go index 8904734..f71402b 100644 --- a/playground/manifest.go +++ b/playground/manifest.go @@ -279,6 +279,7 @@ type Service struct { Tag string `json:"tag,omitempty"` Image string `json:"image,omitempty"` Entrypoint string `json:"entrypoint,omitempty"` + Privileged bool `json:"privileged,omitempty"` } type instance struct { @@ -409,6 +410,11 @@ func (s *Service) WithArgs(args ...string) *Service { return s } +func (s *Service) WithPrivileged() *Service { + s.Privileged = true + return s +} + func (s *Service) WithVolume(name string, localPath string) *Service { if s.VolumesMapped == nil { s.VolumesMapped = make(map[string]string) @@ -417,6 +423,20 @@ func (s *Service) WithVolume(name string, localPath string) *Service { return s } +// WithAbsoluteVolume adds a volume mapping using an absolute path on the host. +// This is useful for binding system paths like /var/run/docker.sock. +// The path must be absolute and will be used as-is without any modification. +func (s *Service) WithAbsoluteVolume(containerPath string, hostPath string) *Service { + if !filepath.IsAbs(hostPath) { + panic(fmt.Sprintf("host path must be absolute: %s", hostPath)) + } + if s.VolumesMapped == nil { + s.VolumesMapped = make(map[string]string) + } + s.VolumesMapped[containerPath] = hostPath + return s +} + func (s *Service) WithArtifact(localPath string, artifactName string) *Service { if s.FilesMapped == nil { s.FilesMapped = make(map[string]string)