Fix Docker API compatibility with network alias (#17167)

* Add BaseHostsFile to container configuration
* Do not copy /etc/hosts file from host when creating a container using Docker API

Signed-off-by: Gavin Lam <gavin.oss@tutamail.com>
This commit is contained in:
Gavin Lam
2023-12-11 23:25:51 -05:00
parent 077b000996
commit db68764d8b
13 changed files with 93 additions and 2 deletions

View File

@ -2373,6 +2373,19 @@ func WithGroupEntry(groupEntry string) CtrCreateOption {
}
}
// WithBaseHostsFile sets the option to copy /etc/hosts file.
func WithBaseHostsFile(baseHostsFile string) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
return define.ErrCtrFinalized
}
ctr.config.BaseHostsFile = baseHostsFile
return nil
}
}
// WithMountAllDevices sets the option to mount all of a privileged container's
// host devices
func WithMountAllDevices() CtrCreateOption {