@@ -20,7 +20,7 @@ import (
20
20
"github.com/docker/docker/pkg/idtools"
21
21
"github.com/docker/docker/pkg/stringid"
22
22
"github.com/docker/docker/runconfig"
23
- "github.com/opencontainers/runc/libcontainer /label"
23
+ "github.com/opencontainers/selinux/go-selinux /label"
24
24
)
25
25
26
26
// CreateManagedContainer creates a container that is managed by a Service
@@ -155,6 +155,13 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) (
155
155
return container , nil
156
156
}
157
157
158
+ func toHostConfigSelinuxLabels (labels []string ) []string {
159
+ for i , l := range labels {
160
+ labels [i ] = "label=" + l
161
+ }
162
+ return labels
163
+ }
164
+
158
165
func (daemon * Daemon ) generateSecurityOpt (hostConfig * containertypes.HostConfig ) ([]string , error ) {
159
166
for _ , opt := range hostConfig .SecurityOpt {
160
167
con := strings .Split (opt , "=" )
@@ -167,7 +174,7 @@ func (daemon *Daemon) generateSecurityOpt(hostConfig *containertypes.HostConfig)
167
174
pidMode := hostConfig .PidMode
168
175
privileged := hostConfig .Privileged
169
176
if ipcMode .IsHost () || pidMode .IsHost () || privileged {
170
- return label .DisableSecOpt (), nil
177
+ return toHostConfigSelinuxLabels ( label .DisableSecOpt () ), nil
171
178
}
172
179
173
180
var ipcLabel []string
@@ -181,7 +188,7 @@ func (daemon *Daemon) generateSecurityOpt(hostConfig *containertypes.HostConfig)
181
188
}
182
189
ipcLabel = label .DupSecOpt (c .ProcessLabel )
183
190
if pidContainer == "" {
184
- return ipcLabel , err
191
+ return toHostConfigSelinuxLabels ( ipcLabel ) , err
185
192
}
186
193
}
187
194
if pidContainer != "" {
@@ -192,7 +199,7 @@ func (daemon *Daemon) generateSecurityOpt(hostConfig *containertypes.HostConfig)
192
199
193
200
pidLabel = label .DupSecOpt (c .ProcessLabel )
194
201
if ipcContainer == "" {
195
- return pidLabel , err
202
+ return toHostConfigSelinuxLabels ( pidLabel ) , err
196
203
}
197
204
}
198
205
@@ -202,7 +209,7 @@ func (daemon *Daemon) generateSecurityOpt(hostConfig *containertypes.HostConfig)
202
209
return nil , fmt .Errorf ("--ipc and --pid containers SELinux labels aren't the same" )
203
210
}
204
211
}
205
- return pidLabel , nil
212
+ return toHostConfigSelinuxLabels ( pidLabel ) , nil
206
213
}
207
214
return nil , nil
208
215
}
0 commit comments