Unable to use COPY --from , docker build trying to pull image
Description Docker file
FROM [imageName] AS builder
# Step that fails
COPY --from=builder [file] [destination]
When I try to build the docker file with the above, I get this error: invalid from flag value builder: pull access denied for builder, repository does not exist or may require 'docker login'
I have imageName already pulled locally and I have access to the private repo it lives in. But it seems as though I just have trouble in the copy line. I am running version: 18.09.0
Steps to reproduce the issue:
- Run docker version 18.09.0
- Create docker file with above contents
- Run docker build . -t [image tag]
Describe the results you received:
Seems as though that syntax does not work. I receive the following error:
invalid from flag value [alias name] regardless of what alias I assign. I tried using the index 0 but that threw another error stating:
invalid from flag value 0: refers to current build stage
When I try 1 as the index, I get an out of bounds error which is expected
Describe the results you expected:
I am expecting that the build will work with the syntax --from=builder
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker version:
Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:43 2018
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:55:00 2018
OS/Arch: linux/amd64
Experimental: true
Output of docker info:
Containers: 27
Running: 10
Paused: 0
Stopped: 17
Images: 685
Server Version: 18.09.0
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 local 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.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: KFZT:ZJLY:SIQK:KB2Y:UOWM:KQRU:PDYG:N2O6:CJUI:7CVO:FNO7:TPVK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 25
Goroutines: 52
System Time: 2018-12-10T16:07:48.76739092Z
EventsListeners: 2
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
Additional environment details (AWS, VirtualBox, physical, etc.): Running on a mac I noticed this works on our CI which uses version 17 of docker
You need to have a second stage to use COPY --from you can not point --from to the same stage you are currently changing.
Note that you can also get this error with a true multistage build if you delete a prior stage of the build (say with docker rm $(docker ps -f status=exited -q)) while the remaining stages are still building.
This can be a very frustrating mistake to make because it also deletes the cache so you have to start all over again 😢
@cnrmck Not with buildkit
@tonistiigi What specifically is "Not with buildkit"?
I am having the same error with COPY --from line. I'm new to Docker, would appreciate some help. Not sure what @tonistiigi means by needing to have a second stage.
My docker file:
` FROM node:latest
RUN mkdir -p /src/app/
WORKDIR /src/app ENV PATH /src/app/node_modules/.bin:$PATH
COPY package.json /src/app/
RUN npm install RUN npm install react-scripts -g
ADD src /src/app/src ADD public /src/app/public
COPY . /src/app RUN npm run build
FROM nginx:1.13.12-alpine COPY --from=build /src/app/build /share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]`
What specifically is "Not with buildkit"?
Buildkit is isolated and you can't interfere with the running build by deleting containers or images.
@triusis92
You need to do FROM node:latest AS build on first line
@tonistiigi thank you, that worked perfectly
I'm having a similar issue. An MWE Dockerfile:
FROM erlang:22.0 AS build
COPY ./a_file /
FROM python:3.7-alpine
COPY --from=bulid /a_file .
docker build -t [tag] . with or without --pull yields the following error at the last step:
invalid from flag value bulid: pull access denied for bulid, repository does not exist or may require 'docker login'
docker version output:
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:35:27 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 01:59:36 2019
OS/Arch: linux/amd64
Experimental: false
I'm running Ubuntu 16.04.6 LTS
@adnilsson --from=build not --from=bulid :)
Ah, silly me!
On Wed, Jun 12, 2019 at 7:21 PM Tõnis Tiigi [email protected] wrote:
Closed #1559 https://github.com/docker/cli/issues/1559.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/cli/issues/1559?email_source=notifications&email_token=ACRFMUH62V5M4GHW5L37HKLP2EWABA5CNFSM4GJOWNXKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOR6ESGZI#event-2408129381, or mute the thread https://github.com/notifications/unsubscribe-auth/ACRFMUD72LOZJYUKLG52TXTP2EWABANCNFSM4GJOWNXA .
@adnilsson and @tonistiigi this really helped me! I had the wrong name just now, too! 😹
I am having the similar issue with:
COPY --chown=1000 --from=build /opt/conda/. $CONDA_DIR
The error says: invalid from flag value build: pull access denied for build, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Could you please help me solve this? Thanks!
@anna-codefresh My guess would be that /scala-hello-world-test/target/scala-2.12/scala-hello-world-sample-app_2.12-1.0.jar does not exist inside the build. If you would just comment out the last line and build the image it builds correctly. If you are just trying to test a hello world app you can easily create a scala file with simple code and run it inside the container.
I found this guide to be helpful: https://linuxacademy.com/guide/11919-using-docker-for-scala/
@adnilsson
--from=buildnot--from=bulid:)
oh my god, I had literally same typo, and couldn't figure out what the problem was. Thanks
FROM scratch
COPY --from=builder [file] [destination]
@tonistiigi thank you, that worked perfectly
Can you please share how you fixed?
FROM node:8.9.1
RUN mkdir -p /data/nodeapp
WORKDIR /data/nodeapp
RUN npm install --silent --progress=false -g [email protected]
COPY package.json /data/nodeapp/
RUN yarn global add http-server
COPY . /data/nodeapp/
ENV deploymentEnv dev
RUN npm install --silent
COPY . ./
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /data/nodeapp/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
this is my file content
@anitha-hanumanthaiah , I think it can solve to you:
FROM node:8.9.1 as build
RUN mkdir -p /data/nodeapp
WORKDIR /data/nodeapp
RUN npm install --silent --progress=false -g [email protected]
COPY package.json /data/nodeapp/
RUN yarn global add http-server
COPY . /data/nodeapp/
ENV deploymentEnv dev
RUN npm install --silent
COPY . ./
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /data/nodeapp/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Hey guys! Could someone help with this? Every time, I get pull access denied:
invalid from flag value build: pull access denied for build, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
FROM python:3.9.7 as build
RUN mkdir -p /opt/psmqtt
WORKDIR /opt/psmqtt
RUN mkdir -p /var/log/psmqtt
ENV VIRTUAL_ENV=/opt/psmqtt
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN useradd --create-home psmqtt
USER psmqtt
VOLUME ["/opt/psmqtt/conf"]
ENV PSMQTTCONFIG="/opt/psmqtt/conf/psmqtt.conf"
COPY --from=build --chown=psmqtt /opt/psmqtt $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
CMD python psmqtt.py
What I do wrong?
Guys i solved it, added second FROM, but got another trouble with the image as well. Python can't find file location but it's another issue... I think at my dockerfile...
The same issue: failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount048400018/app/dist: lstat /var/lib/docker/tmp/buildkit-mount048400018/app/dist: no such file or directory. How to fix I need to fix those issues. This is my dockerfile content
FROM node:latest as build
WORKDIR /usr/local/app
COPY package*.json .
COPY ./ /usr/local/app/
RUN rm -rf node_modules
RUN npm install
RUN npm run build
FROM nginx:latest
Copy ./nginx/nginx.conf /etc/nginx/nginx.conf
WORKDIR /usr/local/app
COPY --from=build /app/dist/Angular13Crud/ /usr/share/nginx/html
EXPOSE 80