diff --git a/lifecycle.go b/lifecycle.go index 1087f5037d..b069c77d44 100644 --- a/lifecycle.go +++ b/lifecycle.go @@ -228,7 +228,16 @@ var defaultReadinessHook = func() ContainerLifecycleHooks { // having entries in exposedAndMappedPorts, where the key is the exposed port, // and the value is the mapped port, means that the port has been already mapped. if _, ok := exposedAndMappedPorts[portMap]; !ok { - return fmt.Errorf("port %s is not mapped yet", exposedPort) + // check if the port is mapped with the protocol (default is TCP) + if !strings.Contains(exposedPort, "/") { + portMap = nat.Port(fmt.Sprintf("%s/tcp", exposedPort)) + if _, ok := exposedAndMappedPorts[portMap]; !ok { + return fmt.Errorf("port %s is not mapped yet", exposedPort) + } + } else { + return fmt.Errorf("port %s is not mapped yet", exposedPort) + } + } } diff --git a/port_forwarding.go b/port_forwarding.go index f1b3962247..89aac10dd7 100644 --- a/port_forwarding.go +++ b/port_forwarding.go @@ -24,7 +24,7 @@ const ( // using the SSHD container as a bridge. HostInternal string = "host.testcontainers.internal" user string = "root" - sshPort = "22" + sshPort = "22/tcp" ) // sshPassword is a random password generated for the SSHD container.