|
@@ -16,6 +16,7 @@ import (
|
|
"github.com/docker/docker/api/types/backend"
|
|
"github.com/docker/docker/api/types/backend"
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/docker/docker/api/types/filters"
|
|
|
|
+ "github.com/docker/docker/api/types/mount"
|
|
"github.com/docker/docker/api/types/versions"
|
|
"github.com/docker/docker/api/types/versions"
|
|
containerpkg "github.com/docker/docker/container"
|
|
containerpkg "github.com/docker/docker/container"
|
|
"github.com/docker/docker/errdefs"
|
|
"github.com/docker/docker/errdefs"
|
|
@@ -513,9 +514,42 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if hostConfig != nil && versions.LessThan(version, "1.42") {
|
|
|
|
+ for _, m := range hostConfig.Mounts {
|
|
|
|
+ // Ignore BindOptions.CreateMountpoint because it was added in API 1.42.
|
|
|
|
+ if bo := m.BindOptions; bo != nil {
|
|
|
|
+ bo.CreateMountpoint = false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // These combinations are invalid, but weren't validated in API < 1.42.
|
|
|
|
+ // We reset them here, so that validation doesn't produce an error.
|
|
|
|
+ if o := m.VolumeOptions; o != nil && m.Type != mount.TypeVolume {
|
|
|
|
+ m.VolumeOptions = nil
|
|
|
|
+ }
|
|
|
|
+ if o := m.TmpfsOptions; o != nil && m.Type != mount.TypeTmpfs {
|
|
|
|
+ m.TmpfsOptions = nil
|
|
|
|
+ }
|
|
|
|
+ if bo := m.BindOptions; bo != nil {
|
|
|
|
+ // Ignore BindOptions.CreateMountpoint because it was added in API 1.42.
|
|
|
|
+ bo.CreateMountpoint = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if hostConfig != nil && versions.GreaterThanOrEqualTo(version, "1.42") {
|
|
if hostConfig != nil && versions.GreaterThanOrEqualTo(version, "1.42") {
|
|
// Ignore KernelMemory removed in API 1.42.
|
|
// Ignore KernelMemory removed in API 1.42.
|
|
hostConfig.KernelMemory = 0
|
|
hostConfig.KernelMemory = 0
|
|
|
|
+ for _, m := range hostConfig.Mounts {
|
|
|
|
+ if o := m.VolumeOptions; o != nil && m.Type != mount.TypeVolume {
|
|
|
|
+ return errdefs.InvalidParameter(fmt.Errorf("VolumeOptions must not be specified on mount type %q", m.Type))
|
|
|
|
+ }
|
|
|
|
+ if o := m.BindOptions; o != nil && m.Type != mount.TypeBind {
|
|
|
|
+ return errdefs.InvalidParameter(fmt.Errorf("BindOptions must not be specified on mount type %q", m.Type))
|
|
|
|
+ }
|
|
|
|
+ if o := m.TmpfsOptions; o != nil && m.Type != mount.TypeTmpfs {
|
|
|
|
+ return errdefs.InvalidParameter(fmt.Errorf("TmpfsOptions must not be specified on mount type %q", m.Type))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if hostConfig != nil && runtime.GOOS == "linux" && versions.LessThan(version, "1.42") {
|
|
if hostConfig != nil && runtime.GOOS == "linux" && versions.LessThan(version, "1.42") {
|