diff --git a/containerd/containerd.go b/containerd/containerd.go index 423776c..492d7b2 100644 --- a/containerd/containerd.go +++ b/containerd/containerd.go @@ -6,6 +6,7 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/oci" + specs "github.com/opencontainers/runtime-spec/specs-go" ) func (d *Driver) isContainerdRunning() (bool, error) { @@ -68,6 +69,21 @@ func (d *Driver) createContainer(image containerd.Image, containerName, containe opts = append(opts, oci.WithLinuxDevice(device, "rwm")) } + // Set mounts. + mounts := make([]specs.Mount, 0) + for _, mount := range config.Mounts { + m := specs.Mount{} + m.Type = mount.Type + m.Destination = mount.Target + m.Source = mount.Source + m.Options = mount.Options + mounts = append(mounts, m) + } + + if len(mounts) > 0 { + opts = append(opts, oci.WithMounts(mounts)) + } + return d.client.NewContainer( d.ctxContainerd, containerName, diff --git a/go.mod b/go.mod index afb076c..a8e91e4 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,7 @@ require ( github.com/moby/moby v1.13.1 github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618 // indirect github.com/opencontainers/runc v1.0.0-rc8.0.20190611121236-6cc515888830 // indirect + github.com/opencontainers/runtime-spec v1.0.2 github.com/opencontainers/selinux v1.3.1 // indirect github.com/seccomp/libseccomp-golang v0.9.1 // indirect github.com/shirou/gopsutil v2.19.11+incompatible // indirect