summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/containers_create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-12 13:35:00 -0400
committerGitHub <noreply@github.com>2022-04-12 13:35:00 -0400
commita82ec1be458bb0861fdde8351c0474fc3c3fc9e7 (patch)
treed9ff092999119d7910aa1f602103c845b7f8b546 /pkg/api/handlers/libpod/containers_create.go
parent87d129e805c993acbc571597baba8101afd475fe (diff)
parentd8a902a167b91ca4fde4ffeef55e9aa4907ae258 (diff)
downloadpodman-a82ec1be458bb0861fdde8351c0474fc3c3fc9e7.tar.gz
podman-a82ec1be458bb0861fdde8351c0474fc3c3fc9e7.tar.bz2
podman-a82ec1be458bb0861fdde8351c0474fc3c3fc9e7.zip
Merge pull request #13787 from Luap99/nohost-api
API: use no_hosts from containers.conf
Diffstat (limited to 'pkg/api/handlers/libpod/containers_create.go')
-rw-r--r--pkg/api/handlers/libpod/containers_create.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/pkg/api/handlers/libpod/containers_create.go b/pkg/api/handlers/libpod/containers_create.go
index 61f437faf..4f9dc008d 100644
--- a/pkg/api/handlers/libpod/containers_create.go
+++ b/pkg/api/handlers/libpod/containers_create.go
@@ -18,7 +18,18 @@ import (
// the new container ID on success along with any warnings.
func CreateContainer(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
- var sg specgen.SpecGenerator
+ conf, err := runtime.GetConfigNoCopy()
+ if err != nil {
+ utils.InternalServerError(w, err)
+ return
+ }
+
+ // we have to set the default before we decode to make sure the correct default is set when the field is unset
+ sg := specgen.SpecGenerator{
+ ContainerNetworkConfig: specgen.ContainerNetworkConfig{
+ UseImageHosts: conf.Containers.NoHosts,
+ },
+ }
if err := json.NewDecoder(r.Body).Decode(&sg); err != nil {
utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))