SYNOPSIS
use Testcontainers::Module::PostgreSQL qw( postgres_container );
# Quick start with defaults
my $pg = postgres_container();
# Custom configuration
my $pg = postgres_container(
image => 'postgres:15-alpine',
username => 'myuser',
password => 'mypass',
database => 'mydb',
);
# Get connection details
my $host = $pg->host;
my $port = $pg->mapped_port('5432/tcp');
my $dsn = $pg->connection_string; # "postgresql://test:test@localhost:32789/testdb"
# Clean up
$pg->terminate;
DESCRIPTION
Pre-configured PostgreSQL container module, equivalent to Go's testcontainers-go/modules/postgres. Provides a PostgreSQL database ready for testing with sensible defaults.
Create and start a PostgreSQL container. Returns a container object with additional PostgreSQL-specific methods.
Options:
image- Docker image (default:postgres:16-alpine)username- PostgreSQL user (default:test)password- PostgreSQL password (default:test)database- Database name (default:testdb)port- Container port (default:5432/tcp)startup_timeout- Timeout in seconds (default: 60)name- Container name
Returns a PostgreSQL connection string: postgresql://user:pass@host:port/dbname
Returns a DBI-compatible DSN: dbi:Pg:dbname=...;host=...;port=...
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 91:
Unknown directive: =func
- Around line 142:
Unknown directive: =method
- Around line 157:
Unknown directive: =method