commit
4672345bc2
@ -18,13 +18,13 @@ func (d *Driver) pullImage(imageName string) (containerd.Image, error) {
|
||||
return d.client.Pull(d.ctxContainerd, imageName, containerd.WithPullUnpack)
|
||||
}
|
||||
|
||||
func (d *Driver) createContainer(image containerd.Image, containerName, containerSnapshotName, containerdRuntime string) (containerd.Container, error) {
|
||||
func (d *Driver) createContainer(image containerd.Image, containerName, containerSnapshotName, containerdRuntime string, env []string) (containerd.Container, error) {
|
||||
return d.client.NewContainer(
|
||||
d.ctxContainerd,
|
||||
containerName,
|
||||
containerd.WithRuntime(containerdRuntime, nil),
|
||||
containerd.WithNewSnapshot(containerSnapshotName, image),
|
||||
containerd.WithNewSpec(oci.WithImageConfig(image)),
|
||||
containerd.WithNewSpec(oci.WithImageConfig(image), oci.WithEnv(env)),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -292,8 +292,14 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
|
||||
|
||||
d.logger.Info(fmt.Sprintf("Successfully pulled %s image\n", image.Name()))
|
||||
|
||||
// Setup environment variables.
|
||||
var env []string
|
||||
for key, val := range cfg.Env {
|
||||
env = append(env, fmt.Sprintf("%s=%s", key, val))
|
||||
}
|
||||
|
||||
containerSnapshotName := fmt.Sprintf("%s-snapshot", containerName)
|
||||
container, err := d.createContainer(image, containerName, containerSnapshotName, d.config.ContainerdRuntime)
|
||||
container, err := d.createContainer(image, containerName, containerSnapshotName, d.config.ContainerdRuntime, env)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("Error in creating container: %v", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user