diff --git a/container.go b/container.go index 90a7ba91cb..5ee0aac881 100644 --- a/container.go +++ b/container.go @@ -532,7 +532,7 @@ func (c *ContainerRequest) validateMounts() error { if len(hostConfig.Binds) > 0 { for _, bind := range hostConfig.Binds { parts := strings.Split(bind, ":") - if len(parts) != 2 { + if len(parts) != 2 && len(parts) != 3 { return fmt.Errorf("%w: %s", ErrInvalidBindMount, bind) } targetPath := parts[1] diff --git a/container_test.go b/container_test.go index c3581a379e..742a97436e 100644 --- a/container_test.go +++ b/container_test.go @@ -73,11 +73,33 @@ func Test_ContainerValidation(t *testing.T) { }, { Name: "Invalid bind mount", - ExpectedError: "invalid bind mount: /data:/data:/data", + ExpectedError: "invalid bind mount: /data:/data:a:b", ContainerRequest: testcontainers.ContainerRequest{ Image: "redis:latest", HostConfigModifier: func(hc *container.HostConfig) { - hc.Binds = []string{"/data:/data:/data"} + hc.Binds = []string{"/data:/data:a:b"} + }, + }, + }, + { + Name: "bind-options/provided", + ContainerRequest: testcontainers.ContainerRequest{ + Image: "redis:latest", + HostConfigModifier: func(hc *container.HostConfig) { + hc.Binds = []string{ + "/a:/a:nocopy", + "/b:/b:ro", + "/c:/c:rw", + "/d:/d:z", + "/e:/e:Z", + "/f:/f:shared", + "/g:/g:rshared", + "/h:/h:slave", + "/i:/i:rslave", + "/j:/j:private", + "/k:/k:rprivate", + "/l:/l:ro,z,shared", + } }, }, },