mirror of https://github.com/docker/docs.git
add domainname support
This commit is contained in:
parent
49b5c44ee9
commit
0a436e03b8
25
container.go
25
container.go
|
|
@ -11,6 +11,7 @@ import (
|
|||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
|
@ -20,7 +21,6 @@ import (
|
|||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"net"
|
||||
)
|
||||
|
||||
type Container struct {
|
||||
|
|
@ -61,6 +61,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
|
||||
|
|
@ -203,8 +204,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,
|
||||
|
|
@ -692,6 +702,9 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
|||
params = append(params, "-e", "TERM=xterm")
|
||||
}
|
||||
|
||||
params = append(params, "-h", container.Config.Hostname)
|
||||
params = append(params, "-d", container.Config.Domainname)
|
||||
|
||||
// Setup environment
|
||||
params = append(params,
|
||||
"-e", "HOME=/",
|
||||
|
|
@ -813,10 +826,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{}{}
|
||||
}
|
||||
|
|
@ -827,10 +840,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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -92,7 +93,8 @@ func SysInit() {
|
|||
var u = flag.String("u", "", "username or uid")
|
||||
var gw = flag.String("g", "", "gateway address")
|
||||
var workdir = flag.String("w", "", "workdir")
|
||||
|
||||
var hostname = flag.String("h", "", "hostname")
|
||||
var domainname = flag.String("d", "", "domainname")
|
||||
var flEnv ListOpts
|
||||
flag.Var(&flEnv, "e", "Set environment variables")
|
||||
|
||||
|
|
@ -101,6 +103,7 @@ func SysInit() {
|
|||
cleanupEnv(flEnv)
|
||||
setupNetworking(*gw)
|
||||
setupWorkingDirectory(*workdir)
|
||||
setupHostname(*hostname, *domainname)
|
||||
changeUser(*u)
|
||||
executeProgram(flag.Arg(0), flag.Args())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue