@@ -40,6 +40,9 @@ func handleVolumeToMount(
4040) (mount.Mount , error ) {
4141 result := createMountFromVolume (volume )
4242
43+ if volume .Image != nil {
44+ return mount.Mount {}, errors .New ("images options are incompatible with type volume" )
45+ }
4346 if volume .Tmpfs != nil {
4447 return mount.Mount {}, errors .New ("tmpfs options are incompatible with type volume" )
4548 }
@@ -86,6 +89,32 @@ func handleVolumeToMount(
8689 return result , nil
8790}
8891
92+ func handleImageToMount (volume composetypes.ServiceVolumeConfig ) (mount.Mount , error ) {
93+ result := createMountFromVolume (volume )
94+
95+ if volume .Source == "" {
96+ return mount.Mount {}, errors .New ("invalid image source, source cannot be empty" )
97+ }
98+ if volume .Volume != nil {
99+ return mount.Mount {}, errors .New ("volume options are incompatible with type image" )
100+ }
101+ if volume .Bind != nil {
102+ return mount.Mount {}, errors .New ("bind options are incompatible with type image" )
103+ }
104+ if volume .Tmpfs != nil {
105+ return mount.Mount {}, errors .New ("tmpfs options are incompatible with type image" )
106+ }
107+ if volume .Cluster != nil {
108+ return mount.Mount {}, errors .New ("cluster options are incompatible with type image" )
109+ }
110+ if volume .Bind != nil {
111+ result .BindOptions = & mount.BindOptions {
112+ Propagation : mount .Propagation (volume .Bind .Propagation ),
113+ }
114+ }
115+ return result , nil
116+ }
117+
89118func handleBindToMount (volume composetypes.ServiceVolumeConfig ) (mount.Mount , error ) {
90119 result := createMountFromVolume (volume )
91120
@@ -95,6 +124,9 @@ func handleBindToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, er
95124 if volume .Volume != nil {
96125 return mount.Mount {}, errors .New ("volume options are incompatible with type bind" )
97126 }
127+ if volume .Image != nil {
128+ return mount.Mount {}, errors .New ("image options are incompatible with type bind" )
129+ }
98130 if volume .Tmpfs != nil {
99131 return mount.Mount {}, errors .New ("tmpfs options are incompatible with type bind" )
100132 }
@@ -121,6 +153,9 @@ func handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, e
121153 if volume .Volume != nil {
122154 return mount.Mount {}, errors .New ("volume options are incompatible with type tmpfs" )
123155 }
156+ if volume .Image != nil {
157+ return mount.Mount {}, errors .New ("image options are incompatible with type tmpfs" )
158+ }
124159 if volume .Cluster != nil {
125160 return mount.Mount {}, errors .New ("cluster options are incompatible with type tmpfs" )
126161 }
@@ -141,6 +176,9 @@ func handleNpipeToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, e
141176 if volume .Volume != nil {
142177 return mount.Mount {}, errors .New ("volume options are incompatible with type npipe" )
143178 }
179+ if volume .Image != nil {
180+ return mount.Mount {}, errors .New ("image options are incompatible with type npipe" )
181+ }
144182 if volume .Tmpfs != nil {
145183 return mount.Mount {}, errors .New ("tmpfs options are incompatible with type npipe" )
146184 }
@@ -203,6 +241,8 @@ func convertVolumeToMount(
203241 switch volume .Type {
204242 case "volume" , "" :
205243 return handleVolumeToMount (volume , stackVolumes , namespace )
244+ case "image" :
245+ return handleImageToMount (volume )
206246 case "bind" :
207247 return handleBindToMount (volume )
208248 case "tmpfs" :
0 commit comments