View Source Testcontainers.MySqlContainer (testcontainers v1.11.8)

Provides functionality for creating and managing MySQL container configurations.

Summary

Functions

Returns the connection parameters to connect to the database from the host machine.

Retrieves the default Docker image for the MySQL container.

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

Retrieves the default exposed port for the MySQL container.

Creates a new MySqlContainer struct with default configurations.

Returns the port on the host machine where the MySql container is listening.

Set the regular expression to check the image validity.

Overrides the default database used for the MySQL container.

Overrides the default image used for the MySQL container.

Overrides the default password used for the MySQL container.

Overrides the default port used for the MySQL container.

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

Overrides the default user used for the MySQL container.

Overrides the default wait timeout used for the MySQL container.

Functions

connection_parameters(container)

Returns the connection parameters to connect to the database from the host machine.

default_image()

Retrieves the default Docker image for the MySQL container.

default_image_with_tag()

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

default_port()

Retrieves the default exposed port for the MySQL container.

new()

Creates a new MySqlContainer struct with default configurations.

port(container)

Returns the port on the host machine where the MySql container is listening.

with_check_image(config, check_image)

Set the regular expression to check the image validity.

with_database(config, database)

Overrides the default database used for the MySQL container.

Examples

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

with_image(config, image)

Overrides the default image used for the MySQL container.

Examples

iex> config = MySqlContainer.new()
iex> new_config = MySqlContainer.with_image(config, "mysql:4")
iex> new_config.image
"mysql:4"

with_password(config, password)

Overrides the default password used for the MySQL container.

Examples

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

with_persistent_volume(config, persistent_volume)

Callback implementation for Testcontainers.DatabaseBehaviour.with_persistent_volume/2.

with_port(config, port)

Overrides the default port used for the MySQL container.

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

Examples

iex> config = MySqlContainer.new()
iex> new_config = MySqlContainer.with_port(config, 3307)
iex> new_config.port
3307

with_reuse(config, reuse)

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

with_user(config, user)

Overrides the default user used for the MySQL container.

Examples

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

with_wait_timeout(config, wait_timeout)

Overrides the default wait timeout used for the MySQL container.

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

Examples

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