Skip to content

Commit 426e336

Browse files
Move ollama port to a constant and provide new getPort method (#9623)
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
1 parent 037b03c commit 426e336

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/ollama/src/main/java/org/testcontainers/ollama/OllamaContainer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class OllamaContainer extends GenericContainer<OllamaContainer> {
2424

2525
private static final DockerImageName DOCKER_IMAGE_NAME = DockerImageName.parse("ollama/ollama");
2626

27+
private static final int OLLAMA_PORT = 11434;
28+
2729
public OllamaContainer(String image) {
2830
this(DockerImageName.parse(image));
2931
}
@@ -49,7 +51,7 @@ public OllamaContainer(DockerImageName dockerImageName) {
4951
});
5052
}
5153
}
52-
withExposedPorts(11434);
54+
withExposedPorts(OLLAMA_PORT);
5355
}
5456

5557
/**
@@ -74,7 +76,11 @@ public void commitToImage(String imageName) {
7476
}
7577
}
7678

79+
public int getPort() {
80+
return getMappedPort(OLLAMA_PORT);
81+
}
82+
7783
public String getEndpoint() {
78-
return "http://" + getHost() + ":" + getMappedPort(11434);
84+
return "http://" + getHost() + ":" + getPort();
7985
}
8086
}

0 commit comments

Comments
 (0)