亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

測試容器中的卷-go

測試容器中的卷-go

Go
HUX布斯 2022-06-06 16:05:37
我有一個 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.

來自osxia/docker-openldap文檔:

由于啟動腳本會修改 ldif 文件,因此如果您不想覆蓋它們,則必須將 --copy-service 參數添加到入口點。

我將此添加到我的 docker-compose 文件中,但在 Go 代碼中忘記了它。


查看完整回答
反對 回復 2022-06-06
  • 1 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號