mirror of https://github.com/docker/docs.git
Merge pull request #2486 from dongmx/issue2485
issue #2485, In generic driver If a permanent IP address and hostname has alread in /etc/hosts
This commit is contained in:
commit
6583e64e48
|
@ -46,8 +46,15 @@ func (provisioner *GenericProvisioner) SetHostname(hostname string) error {
|
|||
}
|
||||
|
||||
// ubuntu/debian use 127.0.1.1 for non "localhost" loopback hostnames: https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_hostname_resolution
|
||||
if _, err := provisioner.SSHCommand(fmt.Sprintf(
|
||||
"if grep -xq 127.0.1.1.* /etc/hosts; then sudo sed -i 's/^127.0.1.1.*/127.0.1.1 %s/g' /etc/hosts; else echo '127.0.1.1 %s' | sudo tee -a /etc/hosts; fi",
|
||||
if _, err := provisioner.SSHCommand(fmt.Sprintf(`
|
||||
if ! grep -xq .*%s /etc/hosts; then
|
||||
if grep -xq 127.0.1.1.* /etc/hosts; then
|
||||
sudo sed -i 's/^127.0.1.1.*/127.0.1.1 %s/g' /etc/hosts;
|
||||
else
|
||||
echo '127.0.1.1 %s' | sudo tee -a /etc/hosts;
|
||||
fi
|
||||
fi`,
|
||||
hostname,
|
||||
hostname,
|
||||
hostname,
|
||||
)); err != nil {
|
||||
|
|
Loading…
Reference in New Issue