add hostname support

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-07-14 15:07:33 -07:00
parent b3385caa4e
commit 248370469f
5 changed files with 16 additions and 5 deletions

View File

@ -44,6 +44,13 @@ func (t *task) build(slaveID string) {
},
}
if t.config.Hostname != "" {
t.Container.Hostname = proto.String(t.config.Hostname)
if t.config.Domainname != "" {
t.Container.Hostname = proto.String(t.config.Hostname + "." + t.config.Domainname)
}
}
switch t.config.HostConfig.NetworkMode {
case "none":
t.Container.Docker.Network = mesosproto.ContainerInfo_DockerInfo_NONE.Enum()

View File

@ -11,7 +11,7 @@ function teardown() {
start_docker_with_busybox 2
swarm_manage
# run container
docker_swarm run -d -e TEST=true --name test_container busybox sleep 500
docker_swarm run -d -e TEST=true -h hostname.test --name test_container busybox sleep 500
# make sure container exsists
run docker_swarm ps -l
@ -23,6 +23,8 @@ function teardown() {
[ "$status" -eq 0 ]
[[ "${output}" == *"NetworkSettings"* ]]
[[ "${output}" == *"TEST=true"* ]]
[[ "${output}" == *'"Hostname": "hostname"'* ]]
[[ "${output}" == *'"Domainname": "test"'* ]]
# the specific information of swarm node
[[ "${output}" == *'"Node": {'* ]]
[[ "${output}" == *'"Name": "node-'* ]]

View File

@ -8,7 +8,7 @@ function teardown() {
stop_docker
}
@test "docker events" {
@test "mesos - docker events" {
start_docker_with_busybox 2
start_mesos
swarm_manage_mesos

View File

@ -8,12 +8,12 @@ function teardown() {
stop_docker
}
@test "docker inspect" {
@test "mesos - docker inspect" {
start_docker_with_busybox 2
start_mesos
swarm_manage_mesos
# run container
docker_swarm run -d -m 20m -e TEST=true --name test_container busybox sleep 500
docker_swarm run -d -m 20m -e TEST=true -h hostname.test --name test_container busybox sleep 500
# make sure container exsists
run docker_swarm ps -l
@ -25,6 +25,8 @@ function teardown() {
[ "$status" -eq 0 ]
[[ "${output}" == *"NetworkSettings"* ]]
[[ "${output}" == *"TEST=true"* ]]
[[ "${output}" == *'"Hostname": "hostname"'* ]]
[[ "${output}" == *'"Domainname": "test"'* ]]
# the specific information of swarm node
[[ "${output}" == *'"Node": {'* ]]
[[ "${output}" == *'"Name": "node-'* ]]

View File

@ -12,7 +12,7 @@ function execute() {
}
# Tests to run. Defaults to all.
TESTS=${@:-. discovery api mesos}
TESTS=${@:-. discovery api mesos/api}
# Generate a temporary binary for the tests.
export SWARM_BINARY=`mktemp`