Search code examples
dockerdockerfiledocker-build

dockerfile COPY from previous build fails


I'm using a multi-stage builds within my dokcerfile according to docker docs:

FROM node:8 as build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN REACT_APP_BACKEND_BASE_URL=http://localhost:8010 yarn build

FROM mhart/alpine-node:8
RUN yarn global add serve
WORKDIR /app
COPY —-from=build /usr/src/app/build .
#COPY ./build .
CMD serve -p 80 -s .

but I'm getting the following error

Step 8/9 : COPY —-from=build /usr/src/app .
COPY failed: stat /var/lib/docker/tmp/docker-builder527544225/—-from=build: no such file or directory

I also tried the index instead of the name: COPY —-from=0 but still same result.

if I skip first build, I manually kick the yarn build and I copy the build result into the single container

#COPY ./build .

it works fine...

Docker version
Client:
 Version:      17.09.1-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:22:25 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.09.1-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:28:28 2017
 OS/Arch:      linux/amd64
 Experimental: true

Solution

  • You have the wrong type of dash in your Dockerfile. Your line:

    COPY —-from=build /usr/src/app/build .
    

    is not the same as:

    COPY --from=build /usr/src/app/build .