GoLang postgres testcontainers 初始化脚本无效化
时间:2024-02-08
浏览:126
作者:佚名
大家好,我们又见面了啊~本文《GoLang postgres testcontainers 初始化脚本无效化》的内容中将会涉及到等等。如果你正在学习Golang相关知识,欢迎关注我,以后会给大家带来更多Golang相关文章,希望我们能一起进步!下面就开始本文的正式内容~
问题内容
我想使用 init 脚本启动 postgres 容器。
request := testcontainers.containerrequest{
image: "postgres:14.1-alpine",
entrypoint: nil,
env: map[string]string{
"postgres_db": "postgres",
"pguser": "postgres",
"postgres_password": "postgres",
//"pgdata": "postgres",
},
exposedports: []string{"5432"},
bindmounts: map[string]string{
"/media/mihovelgod/Новый том1/goprojects/microservices/sql/go-sql/resources/migrations": "/docker-entrypoint-initdb.d",
},
name: "postgres",
user: "postgres",
waitingfor: wait.forlog("database system is ready to accept connections"),
autoremove: true,
}
container, err = testcontainers.genericcontainer(
test.ctx,
testcontainers.genericcontainerrequest{
containerrequest: request,
started: true,
},
)
if err != nil {
log.panicln(err)
}
我在 log.panicln(err) 中收到以下紧急消息:
failed to create container Error response from daemon invalid mount config for type "bind": bind source path does not exist: /docker-entrypoint-initdb.d
重点是它可以在 docker-compose.yml 中完美运行。 如何解决这个问题?
正确答案
查看 the source,testcontainers 似乎想要 container_path: 。如果您尝试会发生什么:bindmounts 中的 host_path
BindMounts: map[string]string{
"/docker-entrypoint-initdb.d": "/media/mihovelgod/Новый том1/GoProjects/microservices/sql/go-sql/resources/migrations",
},
看起来最新版本的 testcontainers 已完全删除 bindmounts 并用更通用的 mounts 字段替换。
今天带大家了解了的相关知识,希望对你有所帮助;关于Golang的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.20
11.20
11.20
11.20
热门专题
