# `Testcontainers.PostgresContainer`
[🔗](https://github.com/testcontainers/testcontainers-elixir/blob/main/lib/container/postgres_container.ex#L4)

Provides functionality for creating and managing Postgres container configurations.

# `t`

```elixir
@type t() :: %Testcontainers.PostgresContainer{
  check_image: term(),
  database: term(),
  image: term(),
  password: term(),
  persistent_volume: term(),
  port: term(),
  reuse: term(),
  user: term(),
  wait_timeout: term()
}
```

# `connection_parameters`

Returns the connection parameters to connect to the database from the _host machine_.

# `default_image`

Retrieves the default Docker image for the Postgres container.

# `default_image_with_tag`

Retrieves the default Docker image including tag for the Postgres container.

# `default_port`

Retrieves the default exposed port for the Postgres container.

# `new`

Creates a new `PostgresContainer` struct with default configurations.

# `port`

Returns the port on the _host machine_ where the Postgres container is listening.

# `with_check_image`

Set the regular expression to check the image validity.

# `with_database`

Overrides the default database used for the Postgres container.

## Examples

    iex> config = PostgresContainer.new()
    iex> new_config = PostgresContainer.with_database(config, "another-database")
    iex> new_config.database
    "another-database"

# `with_image`

Overrides the default image used for the Postgres container.

## Examples

    iex> config = PostgresContainer.new()
    iex> new_config = PostgresContainer.with_image(config, "postgres:12")
    iex> new_config.image
    "postgres:12"

# `with_password`

Overrides the default password used for the Postgres container.

## Examples

    iex> config = PostgresContainer.new()
    iex> new_config = PostgresContainer.with_password(config, "another-password")
    iex> new_config.password
    "another-password"

# `with_persistent_volume`

# `with_port`

Overrides the default port used for the Postgres container.

Note: this will not change what port the docker container is listening to internally.

## Examples

    iex> config = PostgresContainer.new()
    iex> new_config = PostgresContainer.with_port(config, 2345)
    iex> new_config.port
    2345

# `with_reuse`

Set the reuse flag to reuse the container if it is already running.

# `with_user`

Overrides the default user used for the Postgres container.

## Examples

    iex> config = PostgresContainer.new()
    iex> new_config = PostgresContainer.with_user(config, "another-user")
    iex> new_config.user
    "another-user"

# `with_wait_timeout`

Overrides the default wait timeout used for the Postgres container.

Note: this timeout will be used for each individual wait strategy.

## Examples

    iex> config = PostgresContainer.new()
    iex> new_config = PostgresContainer.with_wait_timeout(config, 8000)
    iex> new_config.wait_timeout
    8000

---

*Consult [api-reference.md](api-reference.md) for complete listing*
