Merge pull request #8020 from erikh/rewrite_hosts_files

Links v2: Mutable network files
This commit is contained in:
Alexandr Morozov
2014-09-15 23:03:30 +04:00
4 changed files with 120 additions and 21 deletions
+1
View File
@@ -78,6 +78,7 @@ type Mount struct {
Destination string `json:"destination"`
Writable bool `json:"writable"`
Private bool `json:"private"`
Slave bool `json:"slave"`
}
// Describes a process that will be run inside a container.
+1
View File
@@ -167,6 +167,7 @@ func (d *driver) setupMounts(container *libcontainer.Config, c *execdriver.Comma
Destination: m.Destination,
Writable: m.Writable,
Private: m.Private,
Slave: m.Slave,
})
}
+23 -4
View File
@@ -43,15 +43,30 @@ func prepareVolumesForContainer(container *Container) error {
func setupMountsForContainer(container *Container) error {
mounts := []execdriver.Mount{
{container.ResolvConfPath, "/etc/resolv.conf", true, true},
{
Source: container.ResolvConfPath,
Destination: "/etc/resolv.conf",
Writable: true,
Slave: true,
},
}
if container.HostnamePath != "" {
mounts = append(mounts, execdriver.Mount{container.HostnamePath, "/etc/hostname", true, true})
mounts = append(mounts, execdriver.Mount{
Source: container.HostnamePath,
Destination: "/etc/hostname",
Writable: true,
Private: true,
})
}
if container.HostsPath != "" {
mounts = append(mounts, execdriver.Mount{container.HostsPath, "/etc/hosts", true, true})
mounts = append(mounts, execdriver.Mount{
Source: container.HostsPath,
Destination: "/etc/hosts",
Writable: true,
Slave: true,
})
}
// Mount user specified volumes
@@ -59,7 +74,11 @@ func setupMountsForContainer(container *Container) error {
// volumes. For instance if you use -v /usr:/usr and the host later mounts /usr/share you
// want this new mount in the container
for r, v := range container.Volumes {
mounts = append(mounts, execdriver.Mount{v, r, container.VolumesRW[r], false})
mounts = append(mounts, execdriver.Mount{
Source: v,
Destination: r,
Writable: container.VolumesRW[r],
})
}
container.command.Mounts = mounts