The ban on Docker image repositories in China has made previously written Dockerfiles unable to build suddenly. Besides using a VPN to pull the images locally and then build, are there any other solutions?
Replace the Docker image repository with another one.
For example: https://gallery.ecr.aws/, this is AWS’s ECR public image repository where we can find replacements for commonly used base images.
For instance, the base images we used before:
FROM docker.io/golang:1.22.1 as builder
And
FROM --platform=linux/amd64 docker.io/alpine:3.18
Can all be searched on the https://gallery.ecr.aws/ website.
For example, docker.io/golang:1.22.1, you can search for golang:1.22.1.
Then select the first one, from the Docker official image repository.
Then select “Image tags” to find the image version we need.
Then copy the image repository address and directly replace the original docker.io/golang:1.22.1.
Original:
FROM docker.io/golang:1.22.1 as builder
Replaced:
FROM public.ecr.aws/docker/library/golang:1.22.4-alpine3.20 as builder
Original:
FROM --platform=linux/amd64 docker.io/alpine:3.18
Replaced:
FROM --platform=linux/amd64 public.ecr.aws/docker/library/alpine:3.18