Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
26 changes: 24 additions & 2 deletions container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
},
},
},
Expand Down