summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-04-21 12:29:31 +0200
committerPaul Holzinger <pholzing@redhat.com>2022-04-22 13:06:00 +0200
commite4ab8a5bedb48615402231a5aa3a62ca4364c45f (patch)
tree15392d384af7d761dc1ff9ed97f4a6dbc99c6bc3 /pkg
parentcf1b0c1965c9cc7f3b6d870720ba78865c8602e4 (diff)
downloadpodman-e4ab8a5bedb48615402231a5aa3a62ca4364c45f.tar.gz
podman-e4ab8a5bedb48615402231a5aa3a62ca4364c45f.tar.bz2
podman-e4ab8a5bedb48615402231a5aa3a62ca4364c45f.zip
shared netns and --add-host should conflict
Because /etc/hosts is shared for all containers with a shared network namespace you should not be able to add hosts from a joined container. Only the primary netns container can set the hosts. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgen/container_validate.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/specgen/container_validate.go b/pkg/specgen/container_validate.go
index 42b70e334..e06cd9a29 100644
--- a/pkg/specgen/container_validate.go
+++ b/pkg/specgen/container_validate.go
@@ -38,6 +38,13 @@ func (s *SpecGenerator) Validate() error {
if len(s.PortMappings) > 0 || s.PublishExposedPorts {
return errors.Wrap(define.ErrNetworkOnPodContainer, "published or exposed ports must be defined when the pod is created")
}
+ if len(s.HostAdd) > 0 {
+ return errors.Wrap(define.ErrNetworkOnPodContainer, "extra host entries must be specified on the pod")
+ }
+ }
+
+ if s.NetNS.IsContainer() && len(s.HostAdd) > 0 {
+ return errors.Wrap(ErrInvalidSpecConfig, "cannot set extra host entries when the container is joined to another containers network namespace")
}
//