@@ -11,8 +11,11 @@ import (
11
11
12
12
"github.com/docker/docker/api/types"
13
13
containertypes "github.com/docker/docker/api/types/container"
14
+ "github.com/docker/docker/api/types/versions"
15
+ "github.com/docker/docker/client"
14
16
"github.com/docker/docker/integration/internal/container"
15
17
"github.com/docker/docker/internal/test/daemon"
18
+ "github.com/docker/docker/internal/test/request"
16
19
"gotest.tools/assert"
17
20
is "gotest.tools/assert/cmp"
18
21
"gotest.tools/fs"
@@ -292,3 +295,28 @@ func TestDaemonIpcModeShareableFromConfig(t *testing.T) {
292
295
293
296
testDaemonIpcFromConfig (t , "shareable" , true )
294
297
}
298
+
299
+ // TestIpcModeOlderClient checks that older client gets shareable IPC mode
300
+ // by default, even when the daemon default is private.
301
+ func TestIpcModeOlderClient (t * testing.T ) {
302
+ skip .If (t , versions .LessThan (testEnv .DaemonAPIVersion (), "1.40" ), "requires a daemon with DefaultIpcMode: private" )
303
+ t .Parallel ()
304
+
305
+ ctx := context .Background ()
306
+
307
+ // pre-check: default ipc mode in daemon is private
308
+ c := testEnv .APIClient ()
309
+ cID := container .Create (t , ctx , c , container .WithAutoRemove )
310
+
311
+ inspect , err := c .ContainerInspect (ctx , cID )
312
+ assert .NilError (t , err )
313
+ assert .Check (t , is .Equal (string (inspect .HostConfig .IpcMode ), "private" ))
314
+
315
+ // main check: using older client creates "shareable" container
316
+ c = request .NewAPIClient (t , client .WithVersion ("1.39" ))
317
+ cID = container .Create (t , ctx , c , container .WithAutoRemove )
318
+
319
+ inspect , err = c .ContainerInspect (ctx , cID )
320
+ assert .NilError (t , err )
321
+ assert .Check (t , is .Equal (string (inspect .HostConfig .IpcMode ), "shareable" ))
322
+ }
0 commit comments