@@ -1125,7 +1125,7 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
11251125 }
11261126 }
11271127
1128- bind , vol , tmpfs := buildMountOptions (volume )
1128+ bind , vol , tmpfs , img := buildMountOptions (volume )
11291129
11301130 if bind != nil {
11311131 volume .Type = types .VolumeTypeBind
@@ -1140,37 +1140,35 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
11401140 BindOptions : bind ,
11411141 VolumeOptions : vol ,
11421142 TmpfsOptions : tmpfs ,
1143+ ImageOptions : img ,
11431144 }, nil
11441145}
11451146
1146- func buildMountOptions (volume types.ServiceVolumeConfig ) (* mount.BindOptions , * mount.VolumeOptions , * mount.TmpfsOptions ) {
1147+ func buildMountOptions (volume types.ServiceVolumeConfig ) (* mount.BindOptions , * mount.VolumeOptions , * mount.TmpfsOptions , * mount.ImageOptions ) {
1148+ if volume .Type != types .VolumeTypeBind && volume .Bind != nil {
1149+ logrus .Warnf ("mount of type `%s` should not define `bind` option" , volume .Type )
1150+ }
1151+ if volume .Type != types .VolumeTypeVolume && volume .Volume != nil {
1152+ logrus .Warnf ("mount of type `%s` should not define `volume` option" , volume .Type )
1153+ }
1154+ if volume .Type != types .VolumeTypeTmpfs && volume .Tmpfs != nil {
1155+ logrus .Warnf ("mount of type `%s` should not define `tmpfs` option" , volume .Type )
1156+ }
1157+ if volume .Type != types .VolumeTypeImage && volume .Image != nil {
1158+ logrus .Warnf ("mount of type `%s` should not define `image` option" , volume .Type )
1159+ }
1160+
11471161 switch volume .Type {
11481162 case "bind" :
1149- if volume .Volume != nil {
1150- logrus .Warnf ("mount of type `bind` should not define `volume` option" )
1151- }
1152- if volume .Tmpfs != nil {
1153- logrus .Warnf ("mount of type `bind` should not define `tmpfs` option" )
1154- }
1155- return buildBindOption (volume .Bind ), nil , nil
1163+ return buildBindOption (volume .Bind ), nil , nil , nil
11561164 case "volume" :
1157- if volume .Bind != nil {
1158- logrus .Warnf ("mount of type `volume` should not define `bind` option" )
1159- }
1160- if volume .Tmpfs != nil {
1161- logrus .Warnf ("mount of type `volume` should not define `tmpfs` option" )
1162- }
1163- return nil , buildVolumeOptions (volume .Volume ), nil
1165+ return nil , buildVolumeOptions (volume .Volume ), nil , nil
11641166 case "tmpfs" :
1165- if volume .Bind != nil {
1166- logrus .Warnf ("mount of type `tmpfs` should not define `bind` option" )
1167- }
1168- if volume .Volume != nil {
1169- logrus .Warnf ("mount of type `tmpfs` should not define `volume` option" )
1170- }
1171- return nil , nil , buildTmpfsOptions (volume .Tmpfs )
1167+ return nil , nil , buildTmpfsOptions (volume .Tmpfs ), nil
1168+ case "image" :
1169+ return nil , nil , nil , buildImageOptions (volume .Image )
11721170 }
1173- return nil , nil , nil
1171+ return nil , nil , nil , nil
11741172}
11751173
11761174func buildBindOption (bind * types.ServiceVolumeBind ) * mount.BindOptions {
@@ -1199,7 +1197,7 @@ func buildVolumeOptions(vol *types.ServiceVolumeVolume) *mount.VolumeOptions {
11991197 return & mount.VolumeOptions {
12001198 NoCopy : vol .NoCopy ,
12011199 Subpath : vol .Subpath ,
1202- // Labels: , // FIXME missing from model ?
1200+ Labels : vol . Labels ,
12031201 // DriverConfig: , // FIXME missing from model ?
12041202 }
12051203}
@@ -1214,6 +1212,15 @@ func buildTmpfsOptions(tmpfs *types.ServiceVolumeTmpfs) *mount.TmpfsOptions {
12141212 }
12151213}
12161214
1215+ func buildImageOptions (image * types.ServiceVolumeImage ) * mount.ImageOptions {
1216+ if image == nil {
1217+ return nil
1218+ }
1219+ return & mount.ImageOptions {
1220+ Subpath : image .SubPath ,
1221+ }
1222+ }
1223+
12171224func (s * composeService ) ensureNetwork (ctx context.Context , project * types.Project , name string , n * types.NetworkConfig ) (string , error ) {
12181225 if n .External {
12191226 return s .resolveExternalNetwork (ctx , n )
0 commit comments