mirror of https://github.com/docker/docs.git
Add filesystemtype for containers
If no type is specified then assume aufs.
This commit is contained in:
parent
5892c8e469
commit
80bd64245f
|
|
@ -43,6 +43,7 @@ type Container struct {
|
||||||
ResolvConfPath string
|
ResolvConfPath string
|
||||||
HostnamePath string
|
HostnamePath string
|
||||||
HostsPath string
|
HostsPath string
|
||||||
|
FilesystemType string
|
||||||
|
|
||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
stdout *utils.WriteBroadcaster
|
stdout *utils.WriteBroadcaster
|
||||||
|
|
|
||||||
23
runtime.go
23
runtime.go
|
|
@ -16,6 +16,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultFilesystemType = "devicemapper"
|
||||||
|
)
|
||||||
|
|
||||||
var defaultDns = []string{"8.8.8.8", "8.8.4.4"}
|
var defaultDns = []string{"8.8.8.8", "8.8.4.4"}
|
||||||
|
|
||||||
type Capabilities struct {
|
type Capabilities struct {
|
||||||
|
|
@ -268,9 +272,10 @@ func (runtime *Runtime) restore() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceSet := runtime.deviceSet
|
var (
|
||||||
containers := []*Container{}
|
containers []*Container
|
||||||
containersToMigrate := []*Container{}
|
containersToMigrate []*Container
|
||||||
|
)
|
||||||
|
|
||||||
for i, v := range dir {
|
for i, v := range dir {
|
||||||
id := v.Name()
|
id := v.Name()
|
||||||
|
|
@ -285,12 +290,12 @@ func (runtime *Runtime) restore() error {
|
||||||
utils.Debugf("Loaded container %v", container.ID)
|
utils.Debugf("Loaded container %v", container.ID)
|
||||||
containers = append(containers, container)
|
containers = append(containers, container)
|
||||||
|
|
||||||
if !deviceSet.HasDevice(container.ID) {
|
if container.FilesystemType != DefaultFilesystemType {
|
||||||
containersToMigrate = append(containersToMigrate, container)
|
containersToMigrate = append(containersToMigrate, container)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate AUFS containers to device mapper
|
// Migrate containers to the default filesystem type
|
||||||
if len(containersToMigrate) > 0 {
|
if len(containersToMigrate) > 0 {
|
||||||
if err := migrateToDeviceMapper(runtime, containersToMigrate); err != nil {
|
if err := migrateToDeviceMapper(runtime, containersToMigrate); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -366,6 +371,11 @@ func migrateToDeviceMapper(runtime *Runtime, containers []*Container) error {
|
||||||
fmt.Printf("Failed to remove rw layer %s\n", err)
|
fmt.Printf("Failed to remove rw layer %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container.FilesystemType = DefaultFilesystemType
|
||||||
|
if err := container.ToDisk(); err != nil {
|
||||||
|
fmt.Printf("Failed to save filesystem type to disk %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("Successful migration for %s\n", container.ID)
|
fmt.Printf("Successful migration for %s\n", container.ID)
|
||||||
}
|
}
|
||||||
fmt.Printf("Migration complete\n")
|
fmt.Printf("Migration complete\n")
|
||||||
|
|
@ -448,7 +458,8 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) {
|
||||||
Image: img.ID, // Always use the resolved image id
|
Image: img.ID, // Always use the resolved image id
|
||||||
NetworkSettings: &NetworkSettings{},
|
NetworkSettings: &NetworkSettings{},
|
||||||
// FIXME: do we need to store this in the container?
|
// FIXME: do we need to store this in the container?
|
||||||
SysInitPath: sysInitPath,
|
SysInitPath: sysInitPath,
|
||||||
|
FilesystemType: DefaultFilesystemType,
|
||||||
}
|
}
|
||||||
container.root = runtime.containerRoot(container.ID)
|
container.root = runtime.containerRoot(container.ID)
|
||||||
// Step 1: create the container directory.
|
// Step 1: create the container directory.
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ func init() {
|
||||||
os.Setenv("TEST", "1")
|
os.Setenv("TEST", "1")
|
||||||
os.Setenv("DOCKER_LOOPBACK_DATA_SIZE", "209715200") // 200MB
|
os.Setenv("DOCKER_LOOPBACK_DATA_SIZE", "209715200") // 200MB
|
||||||
os.Setenv("DOCKER_LOOPBACK_META_SIZE", "104857600") // 100MB
|
os.Setenv("DOCKER_LOOPBACK_META_SIZE", "104857600") // 100MB
|
||||||
os.Setenv("DOCKER_BASE_FS_SIZE", "157286400") // 150MB
|
os.Setenv("DOCKER_BASE_FS_SIZE", "157286400") // 150MB
|
||||||
|
|
||||||
// Hack to run sys init during unit testing
|
// Hack to run sys init during unit testing
|
||||||
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
|
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
|
||||||
|
|
@ -575,3 +575,15 @@ func TestRestore(t *testing.T) {
|
||||||
}
|
}
|
||||||
container2.State.Running = false
|
container2.State.Running = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContainerCreatedWithDefaultFilesystemType(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
container, _, _ := mkContainer(runtime, []string{"_", "ls", "-al"}, t)
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
|
if container.FilesystemType != DefaultFilesystemType {
|
||||||
|
t.Fatalf("Container filesystem type should be %s but got %s", DefaultFilesystemType, container.FilesystemType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue