cli: 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:

  1. Run docker version 18.09.0
  2. Create docker file with above contents
  3. 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 27 (5 by maintainers)

Most upvoted comments

You need to have a second stage to use COPY --from you can not point --from to the same stage you are currently changing.

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

@adnilsson --from=build not --from=bulid 😃

@adnilsson --from=build not --from=bulid 😃

oh my god, I had literally same typo, and couldn’t figure out what the problem was. Thanks

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

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 😢