Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
| ... | ... |
@@ -195,7 +195,7 @@ func run(b *Builder, args []string, attributes map[string]bool, original string) |
| 195 | 195 |
|
| 196 | 196 |
defer func(cmd []string) { b.Config.Cmd = cmd }(cmd)
|
| 197 | 197 |
|
| 198 |
- log.Debugf("Command to be executed: %v", b.Config.Cmd)
|
|
| 198 |
+ log.Debugf("[BUILDER] Command to be executed: %v", b.Config.Cmd)
|
|
| 199 | 199 |
|
| 200 | 200 |
hit, err := b.probeCache() |
| 201 | 201 |
if err != nil {
|
| ... | ... |
@@ -261,14 +261,14 @@ func entrypoint(b *Builder, args []string, attributes map[string]bool, original |
| 261 | 261 |
parsed := handleJsonArgs(args, attributes) |
| 262 | 262 |
|
| 263 | 263 |
switch {
|
| 264 |
- case len(parsed) == 0: |
|
| 265 |
- // ENTYRPOINT [] |
|
| 266 |
- b.Config.Entrypoint = nil |
|
| 267 | 264 |
case attributes["json"]: |
| 268 | 265 |
// ENTRYPOINT ["echo", "hi"] |
| 269 | 266 |
b.Config.Entrypoint = parsed |
| 267 |
+ case len(parsed) == 0: |
|
| 268 |
+ // ENTRYPOINT [] |
|
| 269 |
+ b.Config.Entrypoint = nil |
|
| 270 | 270 |
default: |
| 271 |
- // ENTYRPOINT echo hi |
|
| 271 |
+ // ENTRYPOINT echo hi |
|
| 272 | 272 |
b.Config.Entrypoint = []string{"/bin/sh", "-c", parsed[0]}
|
| 273 | 273 |
} |
| 274 | 274 |
|
| ... | ... |
@@ -149,7 +149,7 @@ func (b *Builder) Run(context io.Reader) (string, error) {
|
| 149 | 149 |
b.dockerfile = ast |
| 150 | 150 |
|
| 151 | 151 |
// some initializations that would not have been supplied by the caller. |
| 152 |
- b.Config = &runconfig.Config{Entrypoint: []string{}, Cmd: nil}
|
|
| 152 |
+ b.Config = &runconfig.Config{}
|
|
| 153 | 153 |
b.TmpContainers = map[string]struct{}{}
|
| 154 | 154 |
|
| 155 | 155 |
for i, n := range b.dockerfile.Children {
|
| ... | ... |
@@ -87,10 +87,11 @@ func parseLine(line string) (string, *Node, error) {
|
| 87 | 87 |
|
| 88 | 88 |
if sexp.Value != "" || sexp.Next != nil || sexp.Children != nil {
|
| 89 | 89 |
node.Next = sexp |
| 90 |
- node.Attributes = attrs |
|
| 91 |
- node.Original = line |
|
| 92 | 90 |
} |
| 93 | 91 |
|
| 92 |
+ node.Attributes = attrs |
|
| 93 |
+ node.Original = line |
|
| 94 |
+ |
|
| 94 | 95 |
return "", node, nil |
| 95 | 96 |
} |
| 96 | 97 |
|
| ... | ... |
@@ -1362,6 +1362,49 @@ func TestBuildExpose(t *testing.T) {
|
| 1362 | 1362 |
logDone("build - expose")
|
| 1363 | 1363 |
} |
| 1364 | 1364 |
|
| 1365 |
+func TestBuildEmptyEntrypointInheritance(t *testing.T) {
|
|
| 1366 |
+ name := "testbuildentrypointinheritance" |
|
| 1367 |
+ name2 := "testbuildentrypointinheritance2" |
|
| 1368 |
+ defer deleteImages(name, name2) |
|
| 1369 |
+ |
|
| 1370 |
+ _, err := buildImage(name, |
|
| 1371 |
+ `FROM busybox |
|
| 1372 |
+ ENTRYPOINT ["/bin/echo"]`, |
|
| 1373 |
+ true) |
|
| 1374 |
+ if err != nil {
|
|
| 1375 |
+ t.Fatal(err) |
|
| 1376 |
+ } |
|
| 1377 |
+ res, err := inspectField(name, "Config.Entrypoint") |
|
| 1378 |
+ if err != nil {
|
|
| 1379 |
+ t.Fatal(err) |
|
| 1380 |
+ } |
|
| 1381 |
+ |
|
| 1382 |
+ expected := "[/bin/echo]" |
|
| 1383 |
+ if res != expected {
|
|
| 1384 |
+ t.Fatalf("Entrypoint %s, expected %s", res, expected)
|
|
| 1385 |
+ } |
|
| 1386 |
+ |
|
| 1387 |
+ _, err = buildImage(name2, |
|
| 1388 |
+ fmt.Sprintf(`FROM %s |
|
| 1389 |
+ ENTRYPOINT []`, name), |
|
| 1390 |
+ true) |
|
| 1391 |
+ if err != nil {
|
|
| 1392 |
+ t.Fatal(err) |
|
| 1393 |
+ } |
|
| 1394 |
+ res, err = inspectField(name2, "Config.Entrypoint") |
|
| 1395 |
+ if err != nil {
|
|
| 1396 |
+ t.Fatal(err) |
|
| 1397 |
+ } |
|
| 1398 |
+ |
|
| 1399 |
+ expected = "[]" |
|
| 1400 |
+ |
|
| 1401 |
+ if res != expected {
|
|
| 1402 |
+ t.Fatalf("Entrypoint %s, expected %s", res, expected)
|
|
| 1403 |
+ } |
|
| 1404 |
+ |
|
| 1405 |
+ logDone("build - empty entrypoint inheritance")
|
|
| 1406 |
+} |
|
| 1407 |
+ |
|
| 1365 | 1408 |
func TestBuildEmptyEntrypoint(t *testing.T) {
|
| 1366 | 1409 |
name := "testbuildentrypoint" |
| 1367 | 1410 |
defer deleteImages(name) |
| ... | ... |
@@ -88,7 +88,10 @@ func Merge(userConf, imageConf *Config) error {
|
| 88 | 88 |
if len(userConf.Cmd) == 0 {
|
| 89 | 89 |
userConf.Cmd = imageConf.Cmd |
| 90 | 90 |
} |
| 91 |
- userConf.Entrypoint = imageConf.Entrypoint |
|
| 91 |
+ |
|
| 92 |
+ if userConf.Entrypoint == nil {
|
|
| 93 |
+ userConf.Entrypoint = imageConf.Entrypoint |
|
| 94 |
+ } |
|
| 92 | 95 |
} |
| 93 | 96 |
if userConf.WorkingDir == "" {
|
| 94 | 97 |
userConf.WorkingDir = imageConf.WorkingDir |