Permission denied WHILE building image

I have a Dockefile which works on my laptop (Windows 10 in WSL)
it starts with thу following

Creating multi-stage build for production

FROM node:18-alpine as build
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev > /dev/null 2>&1

But when I run it on one of my servers I get

Step 2/24 : RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev > /dev/null 2>&1
—> Running in eef8c9a406ec
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.18/main: Permission denied
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.18/community: Permission denied
4 unavailable, 0 stale; 17 distinct packages available
The command ‘/bin/sh -c apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev > /dev/null 2>&1’ returned a non-zero code: 4

I tried to add a user to docker group but this did not help but when I run this build command by root - all is ok. But I need to be able to run it under the ordinary user
What is the reason of this error and how can I fix this?

What kind of server are you running? Did you install “root-less” Docker when trying to run as a different user?

It’s Oracle Linux Server release 8.6
By rootless you mean this? I do not think so. I was just given the server to build there images (though I have root there)
I have added the dashboard user to docker group and using visudo have set this
dashboard ALL=(ALL) NOPASSWD: /usr/bin/docker
The thing is that I can run docker hello world under this user and it says that all is ok

docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:88ec0acaa3ec199d3b7eaf73588f4518c25f9d34f58ce9a0df68429c5af48e8d
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
    (amd64)
  3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

But can’t understand why running some commands in a container throws this error

=> ERROR [stage-1 2/7] RUN apk add --no-cache vips-dev 3.6s

[stage-1 2/7] RUN apk add --no-cache vips-dev:
3.263 fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
3.410 fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
3.410 WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.18/main: Permission denied
3.461 WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.18/community: Permission denied
3.461 ERROR: unable to select packages:
3.461 vips-dev (no such package):
3.461 required by: world[vips-dev]


Dockerfile.prod:18

16 | # Creating final production image
17 | FROM node:16-alpine
18 | >>> RUN apk add --no-cache vips-dev
19 | ARG NODE_ENV=production
20 | ENV NODE_ENV=${NODE_ENV}

ERROR: failed to solve: process “/bin/sh -c apk add --no-cache vips-dev” did not complete successfully: exit code: 1

The code of Dockerfile was taken here with this line

RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git

If you don’t run Docker root-less I would think you need to use root :sunglasses:

The error is probably that the non-root user is downloading data from Internet and trying to write the image file to local disk - but has no permission. Images go in a special a Docker folder.

Weird (
But ok, I’ll think I’ll set up a sudo then to make it work correctly