Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get the image from the http repository (http: server gave HTTP response to HTTPS client) #5667

Open
lomtom opened this issue Jan 16, 2025 · 2 comments

Comments

@lomtom
Copy link

lomtom commented Jan 16, 2025

I built the image with k8s + job, but I couldn't get the mirror image after FROM in Dockerfile.

apiVersion: batch/v1
kind: Job
metadata:
  name: buildkit
spec:
  template:
    metadata:
      annotations:
        container.apparmor.security.beta.kubernetes.io/buildkit: unconfined
    # see buildkit/docs/rootless.md for caveats of rootless mode
    spec:
      restartPolicy: Never
      initContainers:
        - name: prepare-dockerfile
          image: swr.cn-east-3.myhuaweicloud.com/lomtom-common/bash:5
          command:
            - sh
            - -c
            - |
              cat > /workspace/Dockerfile <<EOF
              FROM 192.168.80.235:32255/ouyanglongtong/bash:5
              EOF
          securityContext:
            runAsUser: 1000
            runAsGroup: 1000
          volumeMounts:
            - name: workspace
              mountPath: /workspace
        - name: prepare-docker-config
          image: swr.cn-east-3.myhuaweicloud.com/lomtom-common/bash:5
          command:
            - /bin/sh
            - -c
            - "echo '{\"auths\":{\"192.168.80.235:32255\":{\"auth\":\"*********\"}}}' > /workspace/config.json && cat /workspace/config.json"
          securityContext:
            runAsUser: 1000
            runAsGroup: 1000
          volumeMounts:
            - mountPath: /workspace
              name:  workspace
      containers:
        - name: buildkit
          image: swr.cn-east-3.myhuaweicloud.com/lomtom-common/buildkit:v0.18.2-rootless
          env:
            - name: BUILDKITD_FLAGS
              value: --oci-worker-no-process-sandbox
            - name: DOCKER_CONFIG
              value: /workspace
          command:
            - buildctl-daemonless.sh
          args:
            - build
            - --frontend
            - dockerfile.v0
            - --local
            - context=/workspace
            - --local
            - dockerfile=/workspace
            - --opt
            - platform=linux/amd64,linux/arm64
            - --output
            - type=image,name=192.168.80.235:32255/ouyanglongtong/bash:5-1,push=true,registry.insecure=true
          securityContext:
            # Needs Kubernetes >= 1.19
            seccompProfile:
              type: Unconfined
            # To change UID/GID, you need to rebuild the image
            runAsUser: 1000
            runAsGroup: 1000
          volumeMounts:
            - name: workspace
              readOnly: true
              mountPath: /workspace
      volumes:
        - name: workspace
          emptyDir: {}

it will show some error

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile:
#1 transferring dockerfile: 158B done
#1 DONE 0.9s

#2 [linux/amd64 internal] load metadata for 192.168.80.235:32255/ouyanglongtong/bash:5
#2 CANCELED

#3 [linux/arm64 internal] load metadata for 192.168.80.235:32255/ouyanglongtong/bash:5
#3 ERROR: failed to do request: Head "https://192.168.80.235:32255/v2/ouyanglongtong/bash/manifests/5": http: server gave HTTP response to HTTPS client
------
 > [linux/arm64 internal] load metadata for 192.168.80.235:32255/ouyanglongtong/bash:5:
------
Dockerfile:1
--------------------
   1 | >>> FROM 192.168.80.235:32255/ouyanglongtong/bash:5
   2 |     
--------------------
error: failed to solve: 192.168.80.235:32255/ouyanglongtong/bash:5: failed to resolve source metadata for 192.168.80.235:32255/ouyanglongtong/bash:5: failed to do request: Head "https://192.168.80.235:32255/v2/ouyanglongtong/bash/manifests/5": http: server gave HTTP response to HTTPS client

I may not be able to access it because the harbor is http.

But I looked through all the issues and documents, but I couldn't find a solution. What should I do to make it executed correctly?

Thank you

@hf43hf
Copy link

hf43hf commented Jan 17, 2025

I had the same problem

@AkihiroSuda AkihiroSuda changed the title Unable to get the image from the http repository Unable to get the image from the http repository (http: server gave HTTP response to HTTPS client) Jan 17, 2025
@tonistiigi
Copy link
Member

Pulling images from insecure HTTP repositories requires these registries to be defined as insecure in buildkitd TOML config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants