mirror of
https://github.com/docker/compose.git
synced 2025-04-08 17:05:13 +02:00
reject compose file with bind mounts
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
bcd000ab40
commit
4c2ecb542f
@ -155,6 +155,15 @@ func (s *composeService) preChecks(project *types.Project, options api.PublishOp
|
||||
}
|
||||
return acceptPublishEnvVariables(s.dockerCli)
|
||||
}
|
||||
|
||||
for name, config := range project.Services {
|
||||
for _, volume := range config.Volumes {
|
||||
if volume.Type == types.VolumeTypeBind {
|
||||
return false, fmt.Errorf("cannot publish compose file: service %q relies on bind-mount. You should use volumes", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
5
pkg/e2e/fixtures/publish/compose-bind-mount.yml
Normal file
5
pkg/e2e/fixtures/publish/compose-bind-mount.yml
Normal file
@ -0,0 +1,5 @@
|
||||
services:
|
||||
serviceA:
|
||||
image: a
|
||||
volumes:
|
||||
- .:/user-data
|
@ -108,6 +108,12 @@ FOO=bar`), res.Combined())
|
||||
assert.Assert(t, strings.Contains(res.Combined(), `QUIX=`), res.Combined())
|
||||
})
|
||||
|
||||
t.Run("refuse to publish with bind mount", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/publish/compose-bind-mount.yml",
|
||||
"-p", projectName, "alpha", "publish", "test/test", "--dry-run")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 1, Err: `cannot publish compose file: service "serviceA" relies on bind-mount. You should use volumes`})
|
||||
})
|
||||
|
||||
t.Run("refuse to publish with build section only", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmdNoCheck(t, "-f", "./fixtures/publish/compose-build-only.yml",
|
||||
"-p", projectName, "alpha", "publish", "test/test", "--with-env", "-y", "--dry-run")
|
||||
|
Loading…
x
Reference in New Issue
Block a user