【发布时间】:2022-02-01 06:20:33
【问题描述】:
我想用初始化脚本启动 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 中完美运行。 如何解决这个问题?
【问题讨论】:
-
在末尾添加斜线:
/docker-entrypoint-initdb.d/ -
@serge-v 没有帮助,得到了同样的恐慌信息
标签: docker go docker-compose testcontainers