我有一個 docker-compose 文件,我正在嘗試使用testcontainers-go重新創建它:version: '3'services: node1: image: "osixia/openldap:1.3.0" command: ['--copy-service', '--loglevel=debug'] environment: - LDAP_ORGANISATION=Test - LDAP_DOMAIN=test.com - LDAP_BASE_DN=dc=test,dc=com - LDAP_TLS=false ports: - "3898:389" volumes: - "/path/to/testdata/node1.ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom/node1.ldif"下面是go代碼:ldapPort, err := nat.NewPort("tcp", "389")if err != nil { panic(err)}ctx := context.Background()req := testcontainers.ContainerRequest{ Image: imageName, ExposedPorts: []string{ldapPort.Port() + "/" + ldapPort.Proto()}, Env: map[string]string{ "LDAP_ORGANISATION": "Test", "LDAP_DOMAIN": "test.com", "LDAP_BASE_DN": "dc=test,dc=com", "LDAP_TLS": "false", }, BindMounts: map[string]string{ "/path/to/testdata/node1.ldif": "/container/service/slapd/assets/config/bootstrap/ldif/custom/node.ldif", }, WaitingFor: wait.ForLog("slapd starting"),}ldapC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ ContainerRequest: req, Started: true,})if err != nil { panic(err)}defer ldapC.Terminate(ctx)docker-compose 文件工作正常,但是當我嘗試使用 go 運行容器時,容器崩潰,并且它的日志包含以下內容:sed: cannot rename /container/service/slapd/assets/config/bootstrap/ldif/custom/sedah0ove: Device or resource busy我不確定 go 代碼和 docker-compose 聲明之間有什么區別。
1 回答

ibeautiful
TA貢獻1993條經驗 獲得超6個贊
答案實際上在問題中,在這種情況下:
Cmd: []string{"--copy-service"}
需要添加到testcontainers.ContainerRequest
.
由于啟動腳本會修改 ldif 文件,因此如果您不想覆蓋它們,則必須將 --copy-service 參數添加到入口點。
我將此添加到我的 docker-compose 文件中,但在 Go 代碼中忘記了它。
- 1 回答
- 0 關注
- 160 瀏覽
添加回答
舉報
0/150
提交
取消