Skip to content

Commit

Permalink
fix: consider exposed port has no protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Jul 2, 2024
1 parent 5d13313 commit b0c17a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion port_forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b0c17a8

Please sign in to comment.