Skip to content

Commit fb2bb36

Browse files
committed
Replace privileged into other options for creating hosts via DockerIM
1 parent c37890a commit fb2bb36

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pkg/app/instances/docker.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,39 @@ func (m *DockerInstanceManager) createDockerContainer(ctx context.Context, user
372372
Labels: dockerLabelsDict(user),
373373
}
374374
hostConfig := &container.HostConfig{
375+
CapAdd: []string{"NET_ADMIN"},
375376
Mounts: []mount.Mount{
376377
{
377378
Type: mount.TypeVolume,
378379
Source: uaVolumeName(user),
379380
Target: uaMountTarget,
380381
},
381382
},
382-
Privileged: true,
383+
Resources: container.Resources{
384+
Devices: []container.DeviceMapping{
385+
{
386+
PathOnHost: "/dev/kvm",
387+
PathInContainer: "/dev/kvm",
388+
CgroupPermissions: "rwm",
389+
},
390+
{
391+
PathOnHost: "/dev/net/tun",
392+
PathInContainer: "/dev/net/tun",
393+
CgroupPermissions: "rwm",
394+
},
395+
{
396+
PathOnHost: "/dev/vhost-net",
397+
PathInContainer: "/dev/vhost-net",
398+
CgroupPermissions: "rwm",
399+
},
400+
{
401+
PathOnHost: "/dev/vhost-vsock",
402+
PathInContainer: "/dev/vhost-vsock",
403+
CgroupPermissions: "rwm",
404+
},
405+
},
406+
},
407+
SecurityOpt: []string{"seccomp=unconfined"},
383408
}
384409
createRes, err := m.Client.ContainerCreate(ctx, config, hostConfig, nil, nil, "")
385410
if err != nil {

0 commit comments

Comments
 (0)