|
@@ -81,7 +81,9 @@ func (sb *sandbox) buildHostsFile() error {
|
|
|
}
|
|
|
|
|
|
// This is for the host mode networking
|
|
|
- if sb.config.originHostsPath != "" {
|
|
|
+ if sb.config.useDefaultSandBox && len(sb.config.extraHosts) == 0 {
|
|
|
+ // We are working under the assumption that the origin file option had been properly expressed by the upper layer
|
|
|
+ // if not here we are going to error out
|
|
|
if err := copyFile(sb.config.originHostsPath, sb.config.hostsPath); err != nil && !os.IsNotExist(err) {
|
|
|
return types.InternalErrorf("could not copy source hosts file %s to %s: %v", sb.config.originHostsPath, sb.config.hostsPath, err)
|
|
|
}
|
|
@@ -190,8 +192,13 @@ func (sb *sandbox) setupDNS() error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- // This is for the host mode networking
|
|
|
- if sb.config.originResolvConfPath != "" {
|
|
|
+ // When the user specify a conainter in the host namespace and do no have any dns option specified
|
|
|
+ // we just copy the host resolv.conf from the host itself
|
|
|
+ if sb.config.useDefaultSandBox &&
|
|
|
+ len(sb.config.dnsList) == 0 && len(sb.config.dnsSearchList) == 0 && len(sb.config.dnsOptionsList) == 0 {
|
|
|
+
|
|
|
+ // We are working under the assumption that the origin file option had been properly expressed by the upper layer
|
|
|
+ // if not here we are going to error out
|
|
|
if err := copyFile(sb.config.originResolvConfPath, sb.config.resolvConfPath); err != nil {
|
|
|
if !os.IsNotExist(err) {
|
|
|
return fmt.Errorf("could not copy source resolv.conf file %s to %s: %v", sb.config.originResolvConfPath, sb.config.resolvConfPath, err)
|
|
@@ -204,7 +211,12 @@ func (sb *sandbox) setupDNS() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- currRC, err := resolvconf.Get()
|
|
|
+ originResolvConfPath := sb.config.originResolvConfPath
|
|
|
+ if originResolvConfPath == "" {
|
|
|
+ // if not specified fallback to default /etc/resolv.conf
|
|
|
+ originResolvConfPath = resolvconf.DefaultResolvConf
|
|
|
+ }
|
|
|
+ currRC, err := resolvconf.GetSpecific(originResolvConfPath)
|
|
|
if err != nil {
|
|
|
if !os.IsNotExist(err) {
|
|
|
return err
|
|
@@ -271,7 +283,7 @@ func (sb *sandbox) updateDNS(ipv6Enabled bool) error {
|
|
|
)
|
|
|
|
|
|
// This is for the host mode networking
|
|
|
- if sb.config.originResolvConfPath != "" {
|
|
|
+ if sb.config.useDefaultSandBox {
|
|
|
return nil
|
|
|
}
|
|
|
|