|
@@ -11,6 +11,7 @@ import (
|
|
|
"io"
|
|
|
"io/ioutil"
|
|
|
"log"
|
|
|
+ "net"
|
|
|
"os"
|
|
|
"os/exec"
|
|
|
"path"
|
|
@@ -19,7 +20,6 @@ import (
|
|
|
"strings"
|
|
|
"syscall"
|
|
|
"time"
|
|
|
- "net"
|
|
|
)
|
|
|
|
|
|
type Container struct {
|
|
@@ -41,6 +41,8 @@ type Container struct {
|
|
|
|
|
|
SysInitPath string
|
|
|
ResolvConfPath string
|
|
|
+ HostnamePath string
|
|
|
+ HostsPath string
|
|
|
|
|
|
cmd *exec.Cmd
|
|
|
stdout *utils.WriteBroadcaster
|
|
@@ -60,6 +62,7 @@ type Container struct {
|
|
|
|
|
|
type Config struct {
|
|
|
Hostname string
|
|
|
+ Domainname string
|
|
|
User string
|
|
|
Memory int64 // Memory limit (in bytes)
|
|
|
MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap
|
|
@@ -202,8 +205,17 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
|
|
|
return nil, nil, cmd, err
|
|
|
}
|
|
|
|
|
|
+ hostname := *flHostname
|
|
|
+ domainname := ""
|
|
|
+
|
|
|
+ parts := strings.SplitN(hostname, ".", 2)
|
|
|
+ if len(parts) > 1 {
|
|
|
+ hostname = parts[0]
|
|
|
+ domainname = parts[1]
|
|
|
+ }
|
|
|
config := &Config{
|
|
|
- Hostname: *flHostname,
|
|
|
+ Hostname: hostname,
|
|
|
+ Domainname: domainname,
|
|
|
PortSpecs: flPorts,
|
|
|
User: *flUser,
|
|
|
Tty: *flTty,
|
|
@@ -823,10 +835,10 @@ func (container *Container) allocateNetwork() error {
|
|
|
iface = &NetworkInterface{disabled: true}
|
|
|
} else {
|
|
|
iface = &NetworkInterface{
|
|
|
- IPNet: net.IPNet{IP: net.ParseIP(container.NetworkSettings.IPAddress), Mask: manager.bridgeNetwork.Mask},
|
|
|
+ IPNet: net.IPNet{IP: net.ParseIP(container.NetworkSettings.IPAddress), Mask: manager.bridgeNetwork.Mask},
|
|
|
Gateway: manager.bridgeNetwork.IP,
|
|
|
manager: manager,
|
|
|
- }
|
|
|
+ }
|
|
|
ipNum := ipToInt(iface.IPNet.IP)
|
|
|
manager.ipAllocator.inUse[ipNum] = struct{}{}
|
|
|
}
|
|
@@ -837,10 +849,10 @@ func (container *Container) allocateNetwork() error {
|
|
|
portSpecs = container.Config.PortSpecs
|
|
|
} else {
|
|
|
for backend, frontend := range container.NetworkSettings.PortMapping["Tcp"] {
|
|
|
- portSpecs = append(portSpecs, fmt.Sprintf("%s:%s/tcp",frontend, backend))
|
|
|
+ portSpecs = append(portSpecs, fmt.Sprintf("%s:%s/tcp", frontend, backend))
|
|
|
}
|
|
|
for backend, frontend := range container.NetworkSettings.PortMapping["Udp"] {
|
|
|
- portSpecs = append(portSpecs, fmt.Sprintf("%s:%s/udp",frontend, backend))
|
|
|
+ portSpecs = append(portSpecs, fmt.Sprintf("%s:%s/udp", frontend, backend))
|
|
|
}
|
|
|
}
|
|
|
|