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

Consecutive COPY operations causing "layer does not exist" error in 18.06-ce #38866

Open
fractos opened this issue Mar 13, 2019 · 0 comments
Open

Comments

@fractos
Copy link

fractos commented Mar 13, 2019

Description

Seeing a problem with the following Dockerfile on 18.06-ce on Amazon Linux ECS-optimised build, with
Docker using lvs for its storage, with consecutive COPY commands causing "layer does not exist" error.

Steps to reproduce the issue:

  1. Using the following Dockerfile:
FROM microsoft/aspnetcore:2.0

RUN apt-get update \
    && apt-get install -y nginx gettext-base python-pip \
    && pip install awscli \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ENV LISTEN_PORT 80
ENV PROXY_TARGET_HOST 127.0.0.1
ENV PROXY_TARGET_PORT 5000

RUN mkdir -p /var/log/nginx && \
    ln -sf /dev/stdout /var/log/nginx/access.log && \
    ln -sf /dev/stdout /var/log/nginx/error.log

COPY etc/api.nginx.conf /etc/nginx/conf.d/mysite.template

COPY API/bin/Debug/netcoreapp2.0/publish /opt/app
COPY API/appsettings.json /opt/app/
COPY API/log4net.config.xml /opt/app/

COPY etc/run-site.sh /
RUN chmod +x /run-site.sh

ENTRYPOINT ["./run-site.sh"]
CMD ["API.dll"]
  1. docker build -t my-org/my-image:my-tag -f Dockerfile.test .
  2. Same results with adding --no-cache

Describe the results you received:

...
Step 8/14 : COPY API/bin/Debug/netcoreapp2.0/publish /opt/app
 ---> 5765cdff9e66
Step 9/14 : COPY API/appsettings.json /opt/app/
 ---> b90aad29c756
Step 10/14 : COPY API/log4net.config.xml /opt/app/
failed to export image: failed to create image: failed to get layer sha256:8306960c4c2756916ec2882881527b6254b3a08ff467e0c68ab478cdac688125: layer does not exist

Describe the results you expected:
Successfully built image.

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

By re-arranging the instructions in the Dockerfile I was able to get this to build successfully:

FROM microsoft/aspnetcore:2.0

RUN apt-get update \
    && apt-get install -y nginx gettext-base python-pip \
    && pip install awscli \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ENV LISTEN_PORT 80
ENV PROXY_TARGET_HOST 127.0.0.1
ENV PROXY_TARGET_PORT 5000

RUN mkdir -p /var/log/nginx && \
    ln -sf /dev/stdout /var/log/nginx/access.log && \
    ln -sf /dev/stdout /var/log/nginx/error.log

COPY etc/api.nginx.conf /etc/nginx/conf.d/mysite.template

COPY API/bin/Debug/netcoreapp2.0/publish /opt/app
COPY API/appsettings.json /opt/app/
CMD ["API.dll"]
COPY etc/run-site.sh /
RUN chmod +x /run-site.sh
COPY API/log4net.config.xml /opt/app/
ENTRYPOINT ["./run-site.sh"]

... which is obviously a bit of a mess towards the end. Not ideal.

Output of docker version:

Docker version 18.06.1-ce, build e68fc7a215d7133c34aa18e3b72b4a21fd0c6136

Output of docker info:

Containers: 3
 Running: 2
 Paused: 0
 Stopped: 1
Images: 42
Server Version: 18.06.1-ce
Storage Driver: devicemapper
 Pool Name: docker-docker--pool
 Pool Blocksize: 524.3kB
 Base Device Size: 10.74GB
 Backing Filesystem: ext4
 Udev Sync Supported: true
 Data Space Used: 11.06GB
 Data Space Total: 106.1GB
 Data Space Available: 95.02GB
 Metadata Space Used: 2.732MB
 Metadata Space Total: 109.1MB
 Metadata Space Available: 106.3MB
 Thin Pool Minimum Free Space: 10.61GB
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host 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: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.43-17.39.amzn1.x86_64
Operating System: Amazon Linux AMI 2018.03
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.86GiB
Name: ip-10-0-2-91
ID: CMMR:G5V7:7VMV:IFW5:NYLU:MJW7:4DDQ:DO3P:WASJ:BUN6:YCWI:DSQT
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

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

This is an Amazon Linux AMI, one of the ECS-Optimised versions - amzn-ami-2017.03.g-amazon-ecs-optimized (ami-13f7226a). It has been updated with a full sudo yum update operation, including bringing Docker up to version 18.06-ce.

autophagy added a commit to crate/docker-crate that referenced this issue Mar 15, 2019
There seems to be a bug in docker affecting Jenkins' ability (as well as
my own, locally) to build docker images with 3 consecutive COPY/ADD
commands. Previously, this would result in:

```
 ---> d21806a43c11
Step 17/21 : COPY --chown=1000:0 config/crate.yml /crate/config/crate.yml
 ---> d3ce15d62c5f
Step 18/21 : COPY --chown=1000:0 config/log4j2.properties /crate/config/log4j2.properties
 ---> 3e09f7cc5247
Step 19/21 : COPY docker-entrypoint.sh /
failed to export image: failed to create image: failed to get layer sha256:da5198c8160f19dfcd3a574a0ca58243c26e40f9eeacba76a5f5428a41cd7616: layer does not exist
```

Running the docker build a second time would pass successfuly. This has
been reported in multiple places:

moby/moby#37965 (comment)
moby/moby#38866

Moving 2 copy commands before the label and keeping the docker
entrypoint addition afterwards circumvents this issue.

A little ugly, but until it is fixed in Docker, we can't build/deploy
our CrateDB images on Jenkins.
autophagy added a commit to crate/docker-crate that referenced this issue Mar 16, 2019
There seems to be a bug in docker affecting Jenkins' ability (as well as
my own, locally) to build docker images with 3 consecutive COPY/ADD
commands. Previously, this would result in:

```
 ---> d21806a43c11
Step 17/21 : COPY --chown=1000:0 config/crate.yml /crate/config/crate.yml
 ---> d3ce15d62c5f
Step 18/21 : COPY --chown=1000:0 config/log4j2.properties /crate/config/log4j2.properties
 ---> 3e09f7cc5247
Step 19/21 : COPY docker-entrypoint.sh /
failed to export image: failed to create image: failed to get layer sha256:da5198c8160f19dfcd3a574a0ca58243c26e40f9eeacba76a5f5428a41cd7616: layer does not exist
```

Running the docker build a second time would pass successfuly. This has
been reported in multiple places:

moby/moby#37965 (comment)
moby/moby#38866

Moving 2 copy commands before the label and keeping the docker
entrypoint addition afterwards circumvents this issue.

A little ugly, but until it is fixed in Docker, we can't build/deploy
our CrateDB images on Jenkins.
autophagy added a commit to crate/docker-crate that referenced this issue Mar 16, 2019
There seems to be a bug in docker affecting Jenkins' ability (as well as
my own, locally) to build docker images with 3 consecutive COPY/ADD
commands. Previously, this would result in:

```
 ---> d21806a43c11
Step 17/21 : COPY --chown=1000:0 config/crate.yml /crate/config/crate.yml
 ---> d3ce15d62c5f
Step 18/21 : COPY --chown=1000:0 config/log4j2.properties /crate/config/log4j2.properties
 ---> 3e09f7cc5247
Step 19/21 : COPY docker-entrypoint.sh /
failed to export image: failed to create image: failed to get layer sha256:da5198c8160f19dfcd3a574a0ca58243c26e40f9eeacba76a5f5428a41cd7616: layer does not exist
```

Running the docker build a second time would pass successfuly. This has
been reported in multiple places:

moby/moby#37965 (comment)
moby/moby#38866

Moving 2 copy commands before the label and keeping the docker
entrypoint addition afterwards circumvents this issue.

A little ugly, but until it is fixed in Docker, we can't build/deploy
our CrateDB images on Jenkins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants