Dockerfile FROM Insecure Registry
Asked Answered
Z

2

7

Is there a way to build a docker image from a Dockerfile that uses a base image from a local, insecure registry hosted in Gitlab. For example, if my Dockerfile were:

FROM insecure.registry.local:/mygroup/myproject/image:latest

When I run docker build . I get the following error:

failed to solve with frontend dockerfile.v0: failed to create LLB definition:.... http: server gave HTTP response to HTTPS client

When I've been interacting with our registry and received similar types http/https errors, I would alter the docker daemon configuration file to include:

   ...
   "insecure-registries" : ["insecure.registry.local"]
   ...

and everything would work when executing a particular docker command that would trigger it. I'm able to run docker login insecure.registry.local successfully. Is there a way either in the Dockerfile itself, through the docker build command or other alternative to have it pull the image successfully in the FROM statement from an insecure registry?

Zelikow answered 30/7, 2021 at 20:37 Comment(0)
E
8

Depending on your version, you may need to include the scheme in the insecure registry definition. Newer versions of buildkit should not have this issue, so an upgrade may also help.

   ...
   "insecure-registries" : [
     "insecure.registry.local",
     "http://insecure.registry.local"
   ]
   ...
Ezara answered 30/7, 2021 at 22:15 Comment(2)
This seemed to do the trick for me! I would have never guessed to try such a thing, I do appreciate the help! What command should I run to check the version and what version would you expect I wouldn't need to do this with?Zelikow
@Zelikow docker version and docker info will tell you about your docker engine. I'm not sure what release has this fix, but a documentation update was rejected because a commit was made to make it irrelevant. That commit was made July 2020, so at the very least anything before then will have the old behavior. I just don't know when that commit would have been included in the docker engine itself. github.com/docker/docker.github.io/pull/11023Ezara
C
3

Unfortunately there is not that much information about the actual error.

So here are a couple of things that may fix the issue you described:

  • Ensure your file is called Dockerfile (only the D is supposed to be capitalized)
  • Reload and restart the docker daemon after your changes (sudo systemctl daemon-reload && sudo systemctl restart docker)
  • Don't use the docker buildkit (export DOCKER_BUILDKIT=0 && export COMPOSE_DOCKER_CLI_BUILD=0 && docker build .
Cabral answered 30/7, 2021 at 21:25 Comment(1)
Disabling buildkit did it for me.Anatomy

© 2022 - 2024 — McMap. All rights reserved.