| ... | ... |
@@ -271,3 +271,15 @@ func TestDockerRunWithVolumesAsFiles(t *testing.T) {
|
| 271 | 271 |
|
| 272 | 272 |
logDone("run - regression test for #4741 - volumes from as files")
|
| 273 | 273 |
} |
| 274 |
+ |
|
| 275 |
+// Regression test for #4830 |
|
| 276 |
+func TestDockerRunWithRelativePath(t *testing.T) {
|
|
| 277 |
+ runCmd := exec.Command(dockerBinary, "run", "-v", "tmp:/other-tmp", "busybox", "true") |
|
| 278 |
+ if _, _, _, err := runCommandWithStdoutStderr(runCmd); err == nil {
|
|
| 279 |
+ t.Fatalf("relative path should result in an error")
|
|
| 280 |
+ } |
|
| 281 |
+ |
|
| 282 |
+ deleteAllContainers() |
|
| 283 |
+ |
|
| 284 |
+ logDone("run - volume with relative path")
|
|
| 285 |
+} |
| ... | ... |
@@ -172,6 +172,13 @@ func createVolumes(container *Container) error {
|
| 172 | 172 |
if bindMap, exists := binds[volPath]; exists {
|
| 173 | 173 |
isBindMount = true |
| 174 | 174 |
srcPath = bindMap.SrcPath |
| 175 |
+ srcAbs, err := filepath.Abs(srcPath) |
|
| 176 |
+ if err != nil {
|
|
| 177 |
+ return err |
|
| 178 |
+ } |
|
| 179 |
+ if srcPath != srcAbs {
|
|
| 180 |
+ return fmt.Errorf("%s should be an absolute path", srcPath)
|
|
| 181 |
+ } |
|
| 175 | 182 |
if strings.ToLower(bindMap.Mode) == "rw" {
|
| 176 | 183 |
srcRW = true |
| 177 | 184 |
} |