Skip to content

Publishing to ghcr.io with huge layers result in write: connection reset by peer #113

@Deradon

Description

@Deradon

Behaviour

Steps to reproduce this issue

  1. Create a Dockerfile which will result in at least 1 big layer (e.g. RUN npm install with lots of deps)
  2. Use Github Actions w/ shared runners to build such Dockerfile using:
  • docker/setup-buildx-action@v1 and docker/build-push-action@v2

Expected behaviour

Successfully published docker image && layers to ghcr.io and job finishes.

Actual behaviour

Publishing layer results in a error: failed to copy: failed to do request and the job got stuck.

E.g.:

error: failed to copy: failed to do request: Put "https://ghcr.io/v2/deradon/reproduce-gh-buildx-issue/blobs/upload/71fa65fd-f252-4e55-9d68-682c3f8bb02f?digest=sha256%3Af09067957a188c44413d7495878dcb63467764e2f271028891385b9a7482d3a7": write tcp 172.17.0.2:42616->140.82.112.33:443: write: connection reset by peer

NOTE

Not using docker/setup-buildx-action@v1 will result in successful publishing.

Configuration

# .github/workflow/ci.yml
name: CI

on: [push]

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}
  DOCKER_BUILDKIT: 1
  COMPOSE_DOCKER_CLI_BUILD: 1

concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true


jobs:
  build-and-upload-docker-image:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: read
      packages: write
    outputs:
      docker-tag: ${{ steps.meta.outputs.tags }}

    steps:
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        with:
          buildkitd-flags: --debug

      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

      - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          push: true
          file: Dockerfile
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: |
            type=registry,ref=${{ steps.meta.outputs.tags }}
            type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
          cache-to: type=inline

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions