本文整理汇总了Golang中github.com/docker/containerd/execution.Container.ID方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.ID方法的具体用法?Golang Container.ID怎么用?Golang Container.ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/containerd/execution.Container
的用法示例。
在下文中一共展示了Container.ID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Status
func (r *OCIRuntime) Status(ctx context.Context, c *execution.Container) (execution.Status, error) {
state, err := r.runc.State(ctx, c.ID())
if err != nil {
return "", err
}
return execution.Status(state.Status), nil
}
示例2: Delete
func (r *OCIRuntime) Delete(ctx context.Context, c *execution.Container) error {
id := c.ID()
if err := r.runc.Delete(ctx, id); err != nil {
return err
}
c.StateDir().Delete()
r.ios[id].cleanup()
delete(r.ios, id)
return nil
}
示例3: StartProcess
func (r *OCIRuntime) StartProcess(ctx context.Context, c *execution.Container, o execution.StartProcessOpts) (p execution.Process, err error) {
oio, err := newOIO(o.Stdin, o.Stdout, o.Stderr, o.Console)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
oio.cleanup()
}
}()
procStateDir, err := c.StateDir().NewProcess(o.ID)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
c.StateDir().DeleteProcess(o.ID)
}
}()
pidFile := filepath.Join(procStateDir, PidFilename)
if err := r.runc.Exec(ctx, c.ID(), o.Spec, &runc.ExecOpts{
PidFile: pidFile,
Detach: false,
Console: oio.console,
Cwd: o.Spec.Cwd,
IO: oio.rio,
}); err != nil {
return nil, err
}
process, err := newProcess(o.ID, procStateDir, execution.Running)
if err != nil {
return nil, err
}
c.AddProcess(process, false)
r.ios[fmt.Sprintf("%s-%s", c.ID(), process.ID())] = oio
return process, nil
}
示例4: DeleteProcess
func (r *OCIRuntime) DeleteProcess(ctx context.Context, c *execution.Container, id string) error {
ioID := fmt.Sprintf("%s-%s", c.ID(), id)
r.ios[ioID].cleanup()
delete(r.ios, ioID)
return c.StateDir().DeleteProcess(id)
}
示例5: Resume
func (r *OCIRuntime) Resume(ctx context.Context, c *execution.Container) error {
return r.runc.Resume(ctx, c.ID())
}