Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker build exits successfully but fails to build image #35413

Closed
djs55 opened this issue Nov 6, 2017 · 7 comments · Fixed by #35419

Comments

@djs55
Copy link

commented Nov 6, 2017

Description

My docker build -t test . invocation exits with code 0 but the build is not completed and the tag is not created.

Steps to reproduce the issue:

Using the Dockerfile:

FROM alpine AS base

FROM scratch

COPY --from=base /bin /

LABEL foo=bar

# This line is never executed:
CMD /sh

Run the command:

$ docker build -t test .

Describe the results you received:

Sending build context to Docker daemon  31.19MB
Step 1/5 : FROM alpine AS base
latest: Pulling from library/alpine
b56ae66c2937: Pull complete 
Digest: sha256:d6bfc3baf615dc9618209a8d607ba2a8103d9c8a405b3bd8741d88b4bef36478
Status: Downloaded newer image for alpine:latest
 ---> 053cde6e8953
Step 2/5 : FROM scratch
 ---> 
Step 3/5 : COPY --from=base /bin /
 ---> b9b01ebc02ce
Step 4/5 : LABEL foo=bar
$ echo $?
0

Notice how

  • the last step to execute is 4/5
  • no tag is created
  • the command succeeds

If I remove the COPY then it succeeds properly. If I permute the last 2 lines (the LABEL and the CMD after the COPY) then it fails in the same way: always at step 4/5. If I insert additional COPY steps then they execute successfully (but the overall build still fails to complete)

Describe the results you expected:

On 17.09.0-ce it works as follows:

$ docker build -t test .
Sending build context to Docker daemon  31.19MB
Step 1/5 : FROM alpine AS base
latest: Pulling from library/alpine
b56ae66c2937: Pull complete 
Digest: sha256:d6bfc3baf615dc9618209a8d607ba2a8103d9c8a405b3bd8741d88b4bef36478
Status: Downloaded newer image for alpine:latest
 ---> 053cde6e8953
Step 2/5 : FROM scratch
 ---> 
Step 3/5 : COPY --from=base /bin /
 ---> f6ca610bcf97
Step 4/5 : LABEL foo bar
 ---> Running in 8b63bfa48014
 ---> 1046dd92658e
Removing intermediate container 8b63bfa48014
Step 5/5 : CMD /sh
 ---> Running in 764e0e54304c
 ---> 1e6bade266fd
Removing intermediate container 764e0e54304c
Successfully built 1e6bade266fd
Successfully tagged test:latest
$ echo $?
0

Notice

  • all 5/5 steps are executed
  • the tag is created
  • the command exits successfully

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

$ docker version
Client:
 Version:      17.11.0-ce-rc2
 API version:  1.34
 Go version:   go1.8.4
 Git commit:   d7062e5
 Built:        Wed Nov  1 22:08:25 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.11.0-ce-rc2
 API version:  1.34 (minimum version 1.12)
 Go version:   go1.8.5
 Git commit:   d7062e5
 Built:        Wed Nov  1 22:14:52 2017
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

$ docker info
Containers: 10
 Running: 0
 Paused: 0
 Stopped: 10
Images: 104
Server Version: 17.11.0-ce-rc2
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: v1.0.0-beta.2-53-g992280e8 (expected: 992280e8e265f491f7a624ab82f3e238be086e49)
runc version: 0351df1c5a66838d0c392b4ac4cf9450de844e2d
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.44-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: 5QEB:AR7F:CK5A:RJXE:YARC:SWGG:OK56:EMXW:2NTY:HY74:OWT6:6UKE
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 23
 Goroutines: 42
 System Time: 2017-11-06T13:51:06.52057428Z
 EventsListeners: 2
No Proxy: *.local, 169.254.0.0/16, *.io
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

This is Docker for Mac with 17.11.0-ce-rc2.

Version 17.11.0-ce-rc2-mac37 (20033)
Channel: edge
d7d657d636
@thaJeztah

This comment has been minimized.

Copy link
Member

commented Nov 6, 2017

@tonistiigi

This comment has been minimized.

Copy link
Member

commented Nov 6, 2017

@jhowardmsft @johnstep

Seems to be panic on the daemon side that cuts the output. The trace points to the lcow storage split and

return daemon.stores[platform].layerStore.DriverName()
gets called with empty platform variable.

2017-11-06 18:33:16.651675 I | http: panic serving @: runtime error: invalid memory address or nil pointer dereference
goroutine 122 [running]:
net/http.(*conn).serve.func1(0xc420b3a0a0)
	/usr/local/go/src/net/http/server.go:1721 +0xd0
panic(0x1afdb80, 0x2b51dd0)
	/usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/docker/docker/daemon.(*Daemon).GraphDriverName(0xc420310200, 0x0, 0x0, 0xc420f54fc0, 0x40)
	/go/src/github.com/docker/docker/daemon/daemon.go:1110 +0x5f
github.com/docker/docker/daemon.(*Daemon).newContainer(0xc420310200, 0xc420a3bd80, 0x0, 0x0, 0x0, 0xc420b8fcc0, 0xc4209b2000, 0xc420976eb0, 0x47, 0x0, ...)
	/go/src/github.com/docker/docker/daemon/container.go:159 +0x4a5
github.com/docker/docker/daemon.(*Daemon).create(0xc420310200, 0x0, 0x0, 0xc420b8fcc0, 0xc4209b2000, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/docker/docker/daemon/create.go:118 +0x19e
github.com/docker/docker/daemon.(*Daemon).containerCreate(0xc420310200, 0x0, 0x0, 0xc420b8fcc0, 0xc4209b2000, 0x0, 0x0, 0x4ebc00, 0x0, 0x0, ...)
	/go/src/github.com/docker/docker/daemon/create.go:74 +0x1e1
github.com/docker/docker/daemon.(*Daemon).ContainerCreate(0xc420310200, 0x0, 0x0, 0xc420b8fcc0, 0xc4209b2000, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/docker/docker/daemon/create.go:33 +0xa1
github.com/docker/docker/builder/dockerfile.(*containerManager).Create(0xc420b89ea0, 0xc420b8fcc0, 0xc4209b2000, 0x1da0c46, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
@jhowardmsft

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2017

I can’t look until tonight - forced vacation day with no internet access apart from my phone.

@tonistiigi

This comment has been minimized.

Copy link
Member

commented Nov 6, 2017

Same issue without any multi-stage:

FROM scratch
ADD Dockerfile /
ENV foo bar
@johnstep

This comment has been minimized.

Copy link
Member

commented Nov 6, 2017

I'll take a look.

@andrewhsu

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2017

@johnstep had a chat with @tonistiigi ... looking for a test to go along with this as well (should be easy enough to get going with the 3-liner tonis demostrated).

@johnstep

This comment has been minimized.

Copy link
Member

commented Nov 6, 2017

Images created from scratch do not have an OS field, so the following code sets it to an empty string:

os = img.OS

I propose the following actions:

  1. Ensure images built from scratch have the OS field set appropriately.
  2. Never set os to an empty string In daemon.create.
  3. Add a test case, per above, to catch this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.