Skip to content

Commit 0c1c881

Browse files
committed
docs(core): Add an example for configuring a custom DockerContainer with exposed port and environment variable
1 parent 85d6078 commit 0c1c881

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

core/README.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,18 @@ Using `DockerContainer` and `DockerImage` to create a container:
3030

3131
The `DockerImage` class is used to build the image from the specified path and tag.
3232
The `DockerContainer` class is then used to create a container from the image.
33+
34+
35+
Creating a container with an exposed port and a custom environment variable:
36+
37+
.. doctest::
38+
39+
>>> from testcontainers.core.container import DockerContainer
40+
>>> from testcontainers.core.waiting_utils import wait_for_logs
41+
42+
>>> container = DockerContainer("stain/jena-fuseki:latest")
43+
>>> container.with_exposed_ports(3030)
44+
>>> container.with_env("ADMIN_PASSWORD", "password")
45+
>>> container.start()
46+
>>> delay = wait_for_logs(container, "Fuseki is available")
47+
>>> container_url = f"http://{container.get_container_host_ip()}:{container.get_exposed_port(3030)}"

0 commit comments

Comments
 (0)