Esempio n. 1
0
func (daemon *Daemon) createRootfs(container *Container) error {
	// Step 1: create the container directory.
	// This doubles as a barrier to avoid race conditions.
	if err := os.Mkdir(container.root, 0700); err != nil {
		return err
	}
	initID := fmt.Sprintf("%s-init", container.ID)
	if err := daemon.driver.Create(initID, container.ImageID); err != nil {
		return err
	}
	initPath, err := daemon.driver.Get(initID, "")
	if err != nil {
		return err
	}
	defer daemon.driver.Put(initID)

	if err := graph.SetupInitLayer(initPath); err != nil {
		return err
	}

	if err := daemon.driver.Create(container.ID, initID); err != nil {
		return err
	}
	return nil
}
Esempio n. 2
0
func (daemon *Daemon) createTmpRootfs(container *Container) error {
	if _, err := os.Stat(container.root); err != nil && os.IsNotExist(err) {
		return err
	}
	commitID := fmt.Sprintf("%s-commit", container.ID)
	if err := daemon.driver.Create(commitID, container.Image); err != nil {
		return err
	}
	commitPath, err := daemon.driver.Get(commitID, "")
	if err != nil {
		return err
	}
	defer daemon.driver.Put(commitID)

	if err := graph.SetupInitLayer(commitPath); err != nil {
		return err
	}
	return nil
}