func (c *DockerContainer) Ports(ctx context.Context) (nat.PortMap, error) {
	inspect, err := c.inspectContainer(ctx)
	if err != nil {
		return nil, err
	}
	return inspect.NetworkSettings.Ports, nil
}
Ports gets the exposed ports for the container.
package testcontainers
import (
	"bytes"
	"context"
	"fmt"
	"io"
	"io/ioutil"
	"net/url"
	"os"
	"os/exec"
	"strings"
	"github.com/cenkalti/backoff"
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/api/types/container"
	"github.com/docker/docker/api/types/mount"
	"github.com/docker/docker/api/types/network"
	"github.com/docker/docker/client"
	"github.com/docker/docker/pkg/archive"
	"github.com/docker/go-connections/nat"
	"github.com/pkg/errors"
	uuid "github.com/satori/go.uuid"
	"github.com/testcontainers/testcontainers-go/wait"
)
var _ Container = (*DockerContainer)(nil)
type DockerContainer struct {
	ID         string
	WaitingFor wait.Strategy
	raw               *types.ContainerJSON
	provider          *DockerProvider
	sessionID         uuid.UUID
	terminationSignal chan bool
	skipReaper        bool
}
func (c *DockerContainer) GetContainerID() string {
	return c.ID
}
func (c *DockerContainer) Endpoint(ctx context.Context, proto string) (string, error) {
	ports, err := c.Ports(ctx)
	if err != nil {
		return "", err
	}
	var firstPort nat.Port
	for p := range ports {
		firstPort = p
		break
	}
	return c.PortEndpoint(ctx, firstPort, proto)
}
func (c *DockerContainer) PortEndpoint(ctx context.Context, port nat.Port, proto string) (string, error) {
	host, err := c.Host(ctx)
	if err != nil {
		return "", err
	}
	outerPort, err := c.MappedPort(ctx, port)
	if err != nil {
		return "", err
	}
	protoFull := ""
	if proto != "" {
		protoFull = fmt.Sprintf("%s://", proto)
	}
	return fmt.Sprintf("%s%s:%s", protoFull, host, outerPort.Port()), nil
}
func (c *DockerContainer) Host(ctx context.Context) (string, error) {
	host, err := c.provider.daemonHost()
	if err != nil {
		return "", err
	}
	return host, nil
}
func (c *DockerContainer) MappedPort(ctx context.Context, port nat.Port) (nat.Port, error) {
	ports, err := c.Ports(ctx)
	if err != nil {
		return "", err
	}
	for k, p := range ports {
		if k.Port() != port.Port() {
			continue
		}
		if port.Proto() != "" && k.Proto() != port.Proto() {
			continue
		}
		return nat.NewPort(k.Proto(), p[0].HostPort)
	}
	return "", errors.New("port not found")
}