Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaitingFor returns "port not found" if NetworkMode == host #150

Closed
Bablzz opened this issue Feb 11, 2020 · 2 comments
Closed

WaitingFor returns "port not found" if NetworkMode == host #150

Bablzz opened this issue Feb 11, 2020 · 2 comments

Comments

@Bablzz
Copy link
Contributor

Bablzz commented Feb 11, 2020

Describe the bug
WaitingFor returns "port not found" if NetworkMode == host

To Reproduce

func TestContainerWithHostNetworkOptionsAndWaitStrategy(t *testing.T) {
	ctx := context.Background()
	gcr := GenericContainerRequest{ContainerRequest: ContainerRequest{
		Image:       "nginx",
		SkipReaper:  true,
		NetworkMode: "host",
		WaitingFor: wait.ForListeningPort("80/tcp"),
	},
		Started: true,
	}

	nginxC, err := GenericContainer(ctx, gcr)
	if err != nil {
		t.Fatal(err)
	}

	defer nginxC.Terminate(ctx)

	host, err := nginxC.Host(ctx)
	if err != nil {
		t.Errorf("Expected host %s. Got '%d'.", host, err)
	}

	_, err = http.Get("http://" + host + ":80")
	if err != nil {
		t.Errorf("Expected OK response. Got '%d'.", err)
	}
}

Expected behavior
Port found

docker info

Client:
 Debug Mode: false

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 18
 Images: 35
 Server Version: 19.03.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.3.0-29-generic
 Operating System: Ubuntu 19.10
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.34GiB
 Name: 
 ID: 
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional context
In my mind problem in docker.go

func (c *DockerContainer) MappedPort(ctx context.Context, port nat.Port) (nat.Port, error) 
@Bablzz
Copy link
Contributor Author

Bablzz commented Feb 19, 2020

#151

gianarb added a commit that referenced this issue Feb 19, 2020
#150 If networkMode host ForListeningPort does not work
@gianarb
Copy link
Collaborator

gianarb commented Feb 19, 2020

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants