fix docker v2 registry issue

This commit is contained in:
Shubham Agrawal 2020-11-26 16:29:05 +05:30
parent 4be32f2451
commit 2c637d285e
2 changed files with 11 additions and 2 deletions

View File

@ -25,7 +25,7 @@ Build the Docker images with the following commands:
docker build \
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
--file docker/docker/Dockerfile.linux.amd64 --tag plugins/kaniko-docker .
--file docker/docker/Dockerfile.linux.amd64 --tag plugins/kaniko .
docker build \
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \

View File

@ -18,6 +18,9 @@ const (
// Docker file path
dockerPath string = "/kaniko/.docker"
dockerConfigPath string = "/kaniko/.docker/config.json"
v1Registry string = "https://index.docker.io/v1/" // Default registry
v2Registry string = "https://index.docker.io/v2/" // v2 registry is not supported
)
var (
@ -78,7 +81,7 @@ func main() {
cli.StringFlag{
Name: "registry",
Usage: "docker registry",
Value: "https://index.docker.io/v1/",
Value: v1Registry,
EnvVar: "PLUGIN_REGISTRY",
},
cli.StringFlag{
@ -130,6 +133,12 @@ func createDockerCfgFile(username, password, registry string) error {
return fmt.Errorf("Registry must be specified")
}
if registry == v2Registry {
fmt.Println("Docker v2 registry is not supported in kaniko. Refer issue: https://github.com/GoogleContainerTools/kaniko/issues/1209")
fmt.Printf("Using v1 registry instead: %s\n", v1Registry)
registry = v1Registry
}
err := os.MkdirAll(dockerPath, 0600)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("failed to create %s directory", dockerPath))