Pass mount info to containerd.

Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
This commit is contained in:
Shishir Mahajan 2020-06-29 10:26:50 -07:00
parent acf30037b2
commit 910f61de3b
2 changed files with 17 additions and 0 deletions

View File

@ -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,

1
go.mod
View File

@ -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