Docker Community Forums

Share and learn in the Docker community.

COPY command fail while building image from Dockerfile

build
docker

(Matthewee) #1

Hello, I try to build a image from Dockerfile, but always fail at COPY file. I have Fonts dir and contains many font files at my Context.

[root@izwz9ezkmfgg9tv6lcx92lz 200xiang]# ls
Dockerfile  Fonts  requirements.txt
[root@izwz9ezkmfgg9tv6lcx92lz 200xiang]# ls Fonts/
arialbd.ttf  ARIALNBI.TTF  ARIALN.TTF  calibrib.ttf   calibril.ttf  cambriab.ttf  cambriaz.ttf  Deng.ttf    msyh.ttc    simsun.ttc
arialbi.ttf  ARIALNB.TTF   arial.ttf   calibrii.ttf   calibri.ttf   cambriai.ttf  Dengb.ttf     msyhbd.ttc  simhei.ttf  STSONG.TTF
ariali.ttf   ARIALNI.TTF   ariblk.ttf  calibrili.ttf  calibriz.ttf  cambria.ttc   Dengl.ttf     msyhl.ttc   simkai.ttf  方正黑体简体.TTF

My COPY command is.

COPY Fonts/* /usr/share/fonts/ && fc-cache -fv

or

COPY Fonts/ /usr/share/fonts/ && fc-cache -fv

Both fail like:

COPY failed: stat /var/lib/docker/tmp/docker-builder465365949/usr/share/fonts: no such file or directory

How to fix?
My build command

docker build -t 200xiang .

My full Dockerfile:

FROM python:2

# Install OpenJDK-8
RUN apt-get update && \apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;

# Fix certificate issues
RUN apt-get update && \apt-get install ca-certificates-java && \
apt-get clean && \update-ca-certificates -f;

# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME

# Install python libraries
COPY requirements.txt /
RUN pip install --upgrade pip \ 
&& pip install --no-cache-dir -r /requirements.txt

# Install fontsCOPY Fonts  /usr/share/fonts \
COPY Fonts/ /usr/share/fonts/ && fc-cache -fv
CMD ["bash"]

Help me if you meet such error before. Thanks.


(Goffinf) #2

When a build fails you have available the layer immediately prior to that failure. You can spin up a container from that layer, exec in and try your COPY command. It should be self evident what the problem is from there.