code: func (i *ImageService) CommitImage(c backend.CommitConfig) (image.ID, error) {
  	layerStore, ok := i.layerStores[c.ContainerOS]
  	if !ok {
  		return "", system.ErrNotSupportedOperatingSystem
  	}
  	rwTar, err := exportContainerRw(layerStore, c.ContainerID, c.ContainerMountLabel)
  	if err != nil {
  		return "", err
  	}
  	defer func() {
  		if rwTar != nil {
  			rwTar.Close()
  		}
  	}()
  
  	var parent *image.Image
  	if c.ParentImageID == "" {
  		parent = new(image.Image)
  		parent.RootFS = image.NewRootFS()
  	} else {
  		parent, err = i.imageStore.Get(image.ID(c.ParentImageID))
  		if err != nil {
  			return "", err
  		}
  	}
  
  	l, err := layerStore.Register(rwTar, parent.RootFS.ChainID())
  	if err != nil {
  		return "", err
  	}
  	defer layer.ReleaseAndLog(layerStore, l)
  
  	cc := image.ChildConfig{
  		ContainerID:     c.ContainerID,
  		Author:          c.Author,
  		Comment:         c.Comment,
  		ContainerConfig: c.ContainerConfig,
  		Config:          c.Config,
  		DiffID:          l.DiffID(),
  	}
  	config, err := json.Marshal(image.NewChildImage(parent, cc, c.ContainerOS))
  	if err != nil {
  		return "", err
  	}
  
  	id, err := i.imageStore.Create(config)
  	if err != nil {
  		return "", err
  	}
  
  	if c.ParentImageID != "" {
  		if err := i.imageStore.SetParent(id, image.ID(c.ParentImageID)); err != nil {
  			return "", err
  		}
  	}
  	return id, nil
  }
docs: // CommitImage creates a new image from a commit config