What should I do if docker cannot be used in China?

Translation wujiuye 247 0 2024-06-21

This article is a translation of the original text, which can be found at the following link: https://www.wujiuye.com/article/70e3fc311bc64fe2b6f560d9f4591591

Author: wujiuye
Link: https://www.wujiuye.com/article/70e3fc311bc64fe2b6f560d9f4591591
Source: 吴就业的网络日记
This article is an original work by the blogger and is not allowed to be reproduced without the blogger's permission.

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