protected override async Task ProcessRecordAsync()
        {
            foreach (var id in ParameterResolvers.GetContainerIds(Container, ContainerIdOrName))
            {
                ContainerAttachParameters attachParams = null;
                if (this.Attach)
                {
                    attachParams = new ContainerAttachParameters
                    {
                        Stdin  = this.Input,
                        Stdout = true,
                        Stderr = true,
                        Stream = true
                    };
                }

                var cDetail = await DkrClient.Containers.InspectContainerAsync(id);

                await ContainerOperations.StartContainerAsync(
                    this.DkrClient,
                    id,
                    attachParams,
                    cDetail.Config.Tty,
                    null,
                    this.CmdletCancellationToken);

                if (PassThru)
                {
                    WriteObject((await ContainerOperations.GetContainersByIdOrName(id, DkrClient)).Single());
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new container and lists it to output.
        /// </summary>
        protected override async Task ProcessRecordAsync()
        {
            foreach (var id in ParameterResolvers.GetImageIds(Image, ImageIdOrName))
            {
                var createResult = await ContainerOperations.CreateContainer(
                    id,
                    this.MemberwiseClone() as CreateContainerCmdlet,
                    DkrClient);

                if (createResult.Warnings != null)
                {
                    foreach (var w in createResult.Warnings)
                    {
                        if (!String.IsNullOrEmpty(w))
                        {
                            WriteWarning(w);
                        }
                    }
                }

                if (!String.IsNullOrEmpty(createResult.ID))
                {
                    ContainerAttachParameters attachParams = null;
                    if (!Detach)
                    {
                        attachParams = new ContainerAttachParameters
                        {
                            Stdin  = Input,
                            Stdout = true,
                            Stderr = true,
                            Stream = true
                        };
                    }

                    await ContainerOperations.StartContainerAsync(
                        this.DkrClient,
                        createResult.ID,
                        attachParams,
                        this.Terminal,
                        null,
                        this.CmdletCancellationToken);

                    if (RemoveAutomatically && !Detach)
                    {
                        await DkrClient.Containers.RemoveContainerAsync(createResult.ID,
                                                                        new ContainerRemoveParameters());
                    }
                    else if (PassThru)
                    {
                        WriteObject((await ContainerOperations.GetContainersById(createResult.ID, DkrClient)).Single());
                    }
                }
            }
        }