如何在GO代码中拆下ArangodB的测试容器?
我正在尝试使用 https://golang.testcontainers.org 从图像中设置Docker容器我指定,而代码处于执行中。如上所述,将在程序终止之前清理容器,将在程序终止之前进行清理。
这是我必须设置一个“ ArangocontainerRequest”的代码:
arangoContainerRequest := testcontainers.ContainerRequest{
Image: "arangodb/arangodb:3.7.5",
Name: "arango",
ExposedPorts: []string{"8529/tcp"},
Env: map[string]string{
// what config details to specify?
},
WaitingFor: wait.ForLog("Waiting for connections").WithStartupTimeout(time.Minute * 15),
}
这是我必须启动容器并推迟其终止的代码:
arangoContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: arangoContainerRequest,
Started: true,
})
defer arangoContainer.Terminate(ctx)
有了这些代码,我得到了一个超时消息,说“上下文截止日期超过”,其中容器时间甚至没有被创建。
也许对于“ ArangocontainerRequest”地图中“ Env”字段的某些配置值,可以动态启用容器(也许容器不太笨重),但我无法弄清楚它。
任何形式的帮助都将不胜感激。
I'm trying to use https://golang.testcontainers.org to setup a docker container from the image that I specify, while the code is in execution. The container spun out, will be cleaned up before the program terminates, as mentioned in the above link.
This is the code I have to setup an "arangoContainerRequest" :
arangoContainerRequest := testcontainers.ContainerRequest{
Image: "arangodb/arangodb:3.7.5",
Name: "arango",
ExposedPorts: []string{"8529/tcp"},
Env: map[string]string{
// what config details to specify?
},
WaitingFor: wait.ForLog("Waiting for connections").WithStartupTimeout(time.Minute * 15),
}
This is the code I have to start the container up and defer its termination :
arangoContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: arangoContainerRequest,
Started: true,
})
defer arangoContainer.Terminate(ctx)
With these in place, I'm getting a timeout message saying "context deadline exceeded", where the container times out without even being created.
Maybe for some config value for the "Env" field in the "arangoContainerRequest" map, the container can be spun out dynamically (so that maybe the container isn't too bulky), but I'm unable to figure out the same.
Any form of help would be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会考虑查看Arangodb的官方文档,即Docker Hub页面: https:https:// https:// hub.docker.com/_/arangodb
我认为此代码段将帮助您设置容器,因为它对我有用。
I'd consider checking out the official docs for ArangoDB, i.e. the Docker Hub page for it: https://hub.docker.com/_/arangodb
I think this code snippet will help you out in setting up the container, as it works for me.