I have a Dockerfile that builds and runs successfully in Azure pipelines (using docker build task)
When I try to run docker build on my local machine with the same file, apk add [package name] fails, seemingly with an issue finding the alpine repository.
=> ERROR [backend-server 3/4] RUN apk add --no-cache chromium nss freetype freetype-dev harfbuzz 11.4s
------
> [backend-server 3/4] RUN apk add --no-cache chromium nss freetype freetype-dev harfbuzz ca-certificates ttf-freefont nodejs npm:
#6 0.410 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#6 5.416 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#6 5.416 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/main: temporary error (try again later)
#6 10.42 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/community: temporary error (try again later)
#6 10.42 ERROR: unable to select packages:
#6 10.42 ca-certificates (no such package):
#6 10.42 required by: world[ca-certificates]
...
The dockerfile uses node:16.13.0-apline3.14
FROM node:16.13.0-alpine3.14 AS build
WORKDIR /usr/src/app
COPY . ./
RUN npm i
RUN npm run build
WORKDIR /usr/src/app/dist
COPY package*.json ./
RUN npm ci
FROM node:16.13.0-alpine3.14 AS backend-server
WORKDIR /usr/src/app
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
npm
I've tried fetching fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz and the file exists and downloads correctly on my actual computer. I've also tried running by setting the repository (adding apk add -X https://dl-cdn.alpinelinux.org/alpine/v3.14/main), and setting --allow-untrusted, both with exact same results.
The logs in the pipeline show the fetch succeed.
Step 58/72 : RUN apk add --no-cache chromium nss freetype freetype-dev harfbuzz ca-certificates ttf-freefont nodejs npm
---> Running in xxxxxxxxx
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/122) Upgrading zlib (1.2.11-r3 -> 1.2.12-r3)
(2/122) Installing ca-certificates (20220614-r0)
What are other possible causes of this issue, and why would it be different than running in an azure pipeline?
It's probably an issue with your docker desktop's network configuration. You may need to do a clean reinstall of docker desktop to fix the issue.