使用 dimafeng 的Scala 測驗容器,我可以從同一個影像創建多個容器:
class TestWithTwoDatabases extends FunSuite with ForEachTestContainer {
protected val inputContainer: PostgreSQLContainer = PostgreSQLContainer("postgres:13.3")
protected val outputContainer: PostgreSQLContainer = PostgreSQLContainer("postgres:13.3")
override val container: MultipleContainers = MultipleContainers(inputContainer, outputContainer)
// Some integration tests
}
如何在 docker 控制臺中區分它們?我目前有:
CONTAINER ID IMAGE NAMES
a2bee9488c02 postgres:13.3 youthful_archimedes # I'd like to have inputContainer here
2c645ed1c54c postgres:13.3 agitated_cori # I'd like to have outputContainer here
在 Scala 中創建容器時如何指定容器的名稱?
uj5u.com熱心網友回復:
我認為不可能做到這一點。目前還不清楚你為什么需要它。
測驗容器的想法是你可以在你的代碼中使用它們,你可以通過參考來區分它們,inputContainer在outputContainer你的情況下。它并非設計用于以引導框架的形式使用,例如docker compose,因此您可以在代碼外部使用它。
此外,為容器設定一個固定名稱將導致無法在 CI 環境中使用共享 docker 引擎運行聲稱相同容器名稱的測驗。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/450960.html
上一篇:SQLServerException:由于資料工廠中的資料塊活動導致連接關閉
下一篇:ScalaIf和For回圈問題
