get.porter.sh/porter@v1.3.0/pkg/cnab/provider/driver_darwin.go (about)

     1  package cnabprovider
     2  
     3  import (
     4  	"github.com/docker/docker/api/types/container"
     5  	"github.com/docker/docker/api/types/mount"
     6  )
     7  
     8  func (r *Runtime) mountDockerSocket(cfg *container.Config, hostCfg *container.HostConfig) error {
     9  	// Equivalent of using: -v /var/run/docker.sock:/var/run/docker.sock but in a way
    10  	// that works around permission problems because we are running as nonroot
    11  	// See https://github.com/docker/for-mac/issues/4755
    12  	// Required for DooD, or "Docker-out-of-Docker"
    13  	dockerSockMount := mount.Mount{
    14  		Source:   "/var/run/docker.sock.raw",
    15  		Target:   "/var/run/docker.sock",
    16  		Type:     "bind",
    17  		ReadOnly: false,
    18  	}
    19  	hostCfg.Mounts = append(hostCfg.Mounts, dockerSockMount)
    20  	return nil
    21  }
    22  
    23  func (r *Runtime) addVolumeMountToHostConfig(hostConfig *container.HostConfig, source string, target string, readOnly bool) error {
    24  	mount := mount.Mount{
    25  		Source:   source,
    26  		Target:   target,
    27  		Type:     "bind",
    28  		ReadOnly: readOnly,
    29  	}
    30  	hostConfig.Mounts = append(hostConfig.Mounts, mount)
    31  	return nil
    32  }