@@ -4497,3 +4497,33 @@ func (s *DockerSuite) TestRunAddHostInHostMode(c *check.C) {
4497
4497
out , _ := dockerCmd (c , "run" , "--add-host=extra:1.2.3.4" , "--net=host" , "busybox" , "cat" , "/etc/hosts" )
4498
4498
c .Assert (out , checker .Contains , expectedOutput , check .Commentf ("Expected '%s', but got %q" , expectedOutput , out ))
4499
4499
}
4500
+
4501
+ // Test case for #23498
4502
+ func (s * DockerSuite ) TestRunUnsetEntrypoint (c * check.C ) {
4503
+ testRequires (c , DaemonIsLinux )
4504
+ name := "test-entrypoint"
4505
+ dockerfile := `FROM busybox
4506
+ ADD entrypoint.sh /entrypoint.sh
4507
+ RUN chmod 755 /entrypoint.sh
4508
+ ENTRYPOINT ["/entrypoint.sh"]
4509
+ CMD echo foobar`
4510
+
4511
+ ctx , err := fakeContext (dockerfile , map [string ]string {
4512
+ "entrypoint.sh" : `#!/bin/sh
4513
+ echo "I am an entrypoint"
4514
+ exec "$@"` ,
4515
+ })
4516
+ c .Assert (err , check .IsNil )
4517
+ defer ctx .Close ()
4518
+
4519
+ _ , err = buildImageFromContext (name , ctx , true )
4520
+ c .Assert (err , check .IsNil )
4521
+
4522
+ out , _ := dockerCmd (c , "run" , "--entrypoint=" , "-t" , name , "echo" , "foo" )
4523
+ c .Assert (strings .TrimSpace (out ), check .Equals , "foo" )
4524
+
4525
+ // CMD will be reset as well (the same as setting a custom entrypoint)
4526
+ _ , _ , err = dockerCmdWithError ("run" , "--entrypoint=" , "-t" , name )
4527
+ c .Assert (err , check .NotNil )
4528
+ c .Assert (err .Error (), checker .Contains , "No command specified" )
4529
+ }
0 commit comments