Skip to content

build-push-action (docker buildx) does not respect the no_proxy variable. #1223

Open
@snowdream

Description

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

GitHub Actions Continuous Delivery

I want ro run github acion on a self-host pc behind the proxy,but falied.

I can not pull the base image.

The proxy is fine. i can run docker buildx on the pc,but failed when i run github action on it.

Error: buildx failed with: ERROR: failed to solve: alpine:3.20.2: failed to resolve source metadata for docker.io/library/alpine:3.20.2: failed to do request: Head "https://docker.sn0wdr1am.com/v2/library/alpine/manifests/3.20.2?ns=docker.io": proxyconnect tcp: dial tcp 127.0.0.1:1080: connect: connection refused

Expected behaviour

Setup and Run github action on self-host pc behind proxy.

Actual behaviour

I can not pull the base image.

Repository URL

https://github.com/snowdreamtech/alpine

Workflow run URL

https://github.com/snowdreamtech/alpine/actions/workflows/main.yml

YAML workflow

name: GitHub Actions Continuous Delivery

on:
  push:
    branches:
      - main  
    tags:
      - '*'
  workflow_dispatch:
jobs:
    buildx:
      runs-on: whitepi3bplus
      steps:
        -
          name: Checkout
          uses: actions/[email protected]
          with:
            # [Required] Access token with `workflow` scope.
            token: ${{ secrets.WORKFLOW_SECRET }}
        - 
          name: Set env variables
          run: |
            echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
            echo "http_proxy=${http_proxy}" >> $GITHUB_ENV
            echo "no_proxy=${no_proxy}" >> $GITHUB_ENV
        -
          # Add support for more platforms with QEMU (optional)
          # https://github.com/docker/setup-qemu-action
          name: Set up QEMU
          uses: docker/[email protected]
        -
          # https://github.com/docker/setup-buildx-action/issues/57#issuecomment-1059657292
          # https://github.com/docker/buildx/issues/136#issuecomment-550205439
          # docker buildx create --driver-opt env.http_proxy=$http_proxy --driver-opt env.https_proxy=$https_proxy --driver-opt '"env.no_proxy='$no_proxy'"'
          name: Set up Docker Buildx
          uses: docker/[email protected]
          with:
            buildkitd-config: .github/buildkitd.toml
            driver-opts: |
              env.http_proxy=${{ env.http_proxy }}
              env.https_proxy=${{ env.http_proxy }}
              "env.no_proxy='${{ env.no_proxy}}'"
        -
          name: Login to DockerHub
          uses: docker/[email protected]
          with:
            username: ${{ secrets.DOCKER_HUB_USERNAME }}
            password: ${{ secrets.DOCKER_HUB_TOKEN }}
        -
          name: Login to GitHub Container Registry
          uses: docker/[email protected]
          with:
            registry: ghcr.io
            username: ${{ github.repository_owner }}
            password: ${{ secrets.GITHUB_TOKEN }}          
        -
          name: Build and push
          uses: docker/[email protected]
          with:
            context: .
            build-args: |
              "http_proxy=${{ env.http_proxy }}"
              "https_proxy=${{ env.http_proxy }}"
              "no_proxy='${{ env.no_proxy}}'"
            platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x
            push: true
            tags: |
              snowdreamtech/alpine:latest
              snowdreamtech/alpine:3.20.2
              snowdreamtech/alpine:3.20
              snowdreamtech/alpine:3
              ghcr.io/snowdreamtech/alpine:latest
              ghcr.io/snowdreamtech/alpine:3.20.2
              ghcr.io/snowdreamtech/alpine:3.20
              ghcr.io/snowdreamtech/alpine:3

Workflow logs

https://github.com/snowdreamtech/alpine/actions/runs/10643865069/job/29507938882

logs_27827136796.zip

BuildKit logs

No response

Additional info

~/.docker/config.json

{
        "auths": {},
        "proxies": {
                "default": {
                        "httpProxy": "http://127.0.0.1:1080",
                        "httpsProxy": "http://127.0.0.1:1080",
                        "noProxy": "localhost,example.com,sn0wdr1am.com"
                }
        }
}

.github/buildkitd.toml

# debug enables additional debug logging
debug = true
# trace enables additional trace logging (very verbose, with potential performance impacts)
trace = true


[registry."docker.io"]
    mirrors = ["https://docker.sn0wdr1am.com"]

[registry."quay.io"]
    mirrors = ["https://quay.sn0wdr1am.com"]

[registry."gcr.io"]
    mirrors = ["https://gcr.sn0wdr1am.com"]

[registry."k8s.gcr.io"]
    mirrors = ["https://k8s-gcr.sn0wdr1am.com"]

[registry."k8s.io"]
    mirrors = ["https://k8s.sn0wdr1am.com"]

[registry."ghcr.io"]
    mirrors = ["https://ghcr.sn0wdr1am.com"]

[registry."cloudsmith.io"]
    mirrors = ["https://cloudsmith.sn0wdr1am.com"]

[registry."ecr.aws"]
    mirrors = ["https://ecr.sn0wdr1am.com"]

[worker.oci]
  max-parallelism = 2

global proxy

export http_proxy="http://127.0.0.1:1080"
export https_proxy="http://127.0.0.1:1080"
export ftp_proxy="http://127.0.0.1:1080"
export all_proxy="http://127.0.0.1:1080"
export no_proxy="localhost,example.com,sn0wdr1am.com"
export HTTP_PROXY="http://127.0.0.1:1080"
export HTTPS_PROXY="http://127.0.0.1:1080"
export FTP_PROXY="http://127.0.0.1:1080"
export ALL_PROXY="http://127.0.0.1:1080"
export NO_PROXY="localhost,example.com,sn0wdr1am.com"

~/.config/systemd/user/docker.service.d/http-proxy.conf

/etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://127.0.0.1:1080"
Environment="HTTPS_PROXY=http://127.0.0.1:1080"
Environment="NO_PROXY=localhost,example.com,sn0wdr1am.com"

/etc/docker/daemon.json

{
          "experimental": true,
    "registry-mirrors": [
    "https://docker.sn0wdr1am.com", 
    "https://quay.sn0wdr1am.com",   
    "https://gcr.sn0wdr1am.com",    
    "https://k8s-gcr.sn0wdr1am.com",    
    "https://k8s.sn0wdr1am.com",
    "https://ghcr.sn0wdr1am.com",   
    "https://cloudsmith.sn0wdr1am.com", 
    "https://ecr.sn0wdr1am.com"
  ]
}

~/actions-runner/.env

export http_proxy="http://127.0.0.1:1080"
export https_proxy="http://127.0.0.1:1080"
export ftp_proxy="http://127.0.0.1:1080"
export all_proxy="http://127.0.0.1:1080"
export no_proxy="localhost,example.com,sn0wdr1am.com"
export HTTP_PROXY="http://127.0.0.1:1080"
export HTTPS_PROXY="http://127.0.0.1:1080"
export FTP_PROXY="http://127.0.0.1:1080"
export ALL_PROXY="http://127.0.0.1:1080"
export NO_PROXY="localhost,example.com,sn0wdr1am.com"

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions