Docker build not working: rpc error (PROTOCOL_ERROR)

Hello, my OS is Windows 11 Pro Version 21H2 (OS build 22000.527) and my Docker version is:

 Cloud integration: v1.0.22
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:44:07 2021
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.5.1 (74721)
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
  Version:          0.19.0
  GitCommit:        de40ad0

My issue
I’ve been trying to build an image from my Dockerfile but I run into an error when i run docker build .
My dockerfile is the following:

FROM node:latest

WORKDIR /usr/src/app 

COPY package*.json .

RUN npm install

COPY . .

CMD ["npm", "start"]

The output is the following:

docker build .
[+] Building 2.6s (5/9)
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 32B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 35B                                                                                   0.0s
 => [internal] load metadata for                                                     2.6s
 => [1/5] FROM  0.0s
 => ERROR [internal] load build context                                                                            0.0s
 => => transferring context:                                                                                       0.0s
 > [internal] load build context:
rpc error: code = Internal desc = stream terminated by RST_STREAM with error code: PROTOCOL_ERROR

The dockerfile is located in the root of my node project and it’s located in the C drive. I’ve tried running this in the Hyper-V engine, as well as the WSL2 engine, but the output is the same.
I think it fails for some reason when downloading the node:latest image, but if I change it to node:alpine the output is the same. But when I run docker pull node:latest it succeds without any problem.

I’ve also:

  1. Uninstalled Docker Desktop
  2. Restarted my computer
  3. Reinstalled Docker Desktop again

and I still get the same error.
I decided to try the sample application from Sample application | Docker Documentation with the provided Dockerfile:

FROM node:12-alpine
RUN apk add --no-cache python2 g++ make
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]

and when I run docker build -t getting-started . It throws the same error. I’m not sure what to do anymore, any suggestions? Thank you in advance.

Can you build without buildkit enabled? You can disable it in the Docker Engine settings. You should not see this message even with buildkit, but I don’t have better idea right now and if it is a protocol error, it might be related to buildkit. Disabling buildkit doesn’t always help, but if I don’t know the cause of an issue on Windows or Mac where buildkit is enabled, I always recommend to disable it.

I am not surprised since you just renamed your image. If you want to use the getting-started image, you need to pull or run it, not build it.

docker run -d --name getting-started -p 8080:80  docker/getting-started

I just had the same issue. Turned out to be my .dockerignore file causing it. I renamed it to .dockerignore2 just to disable it, and build worked again.


Thank you! This fixed my issue. Any idea why the dockerignore file causes this weird error? I haven’t found anything useful online. Could it be a bug with this specific docker version?

1 Like

Hi! Same issue here. FYI, updating Docker Desktop from version 4.15.X to 4.16.1 fixes the issue and I was finally able to (re)add “node_modules/” in my .dockerignore :raised_hands:.