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

@ -116,6 +116,8 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
}
// moby always create the working directory
sg.CreateWorkingDir = true
// moby doesn't inherit /etc/hosts from host
sg.BaseHostsFile = "none"
ic := abi.ContainerEngine{Libpod: runtime}
report, err := ic.ContainerCreate(r.Context(), sg)