2020-09-21 15:06:04 -04:00
# Troubleshooting
2020-10-23 16:51:59 -04:00
* [Cannot push to a registry ](#cannot-push-to-a-registry )
2021-04-27 10:16:22 -04:00
* [BuildKit container logs ](#buildkit-container-logs )
* [With containerd ](#with-containerd )
2021-08-05 02:09:50 -04:00
* [`repository name must be lowercase` ](#repository-name-must-be-lowercase )
2023-07-03 03:01:27 -04:00
* [Image not loaded ](#image-not-loaded )
2020-10-23 16:51:59 -04:00
## Cannot push to a registry
2020-09-21 15:06:04 -04:00
While pushing to a registry, you may encounter these kinds of issues:
* `failed commit on ref "layer-sha256:...": invalid content digest in response: invalid checksum digest format`
* `failed commit on ref "layer-sha256:...": no response`
2020-10-08 14:37:39 -04:00
* `failed commit on ref "manifest-sha256:...": unexpected status: 400 Bad Request`
2020-09-21 15:06:04 -04:00
* `failed commit on ref "manifest-sha256:...": unexpected status: 401 Unauthorized`
* `unexpected response: 401 Unauthorized`
2021-08-05 02:09:50 -04:00
These issues are not directly related to this action but are rather linked to
2022-10-07 13:16:42 -04:00
[Buildx ](https://github.com/docker/buildx ), [BuildKit ](https://github.com/moby/buildkit ),
2021-08-05 02:09:50 -04:00
[containerd ](https://github.com/containerd/containerd ) or the registry on which
you're pushing your image. The quality of error message depends on the registry
and are usually not very informative.
2020-09-21 15:06:04 -04:00
2021-04-27 10:16:22 -04:00
### BuildKit container logs
2021-04-23 17:34:43 -04:00
To help you solve this, you have to [enable debugging in the setup-buildx ](https://github.com/docker/setup-buildx-action#buildkit-container-logs )
action step and attach BuildKit container logs to your issue.
2020-09-21 15:06:04 -04:00
2021-04-27 10:16:22 -04:00
### With containerd
2021-08-05 02:09:50 -04:00
Next you can test pushing with [containerd action ](https://github.com/crazy-max/ghaction-setup-containerd )
2022-10-07 13:16:42 -04:00
using the following workflow. If it works then open an issue on [BuildKit ](https://github.com/moby/buildkit )
2021-08-05 02:09:50 -04:00
repository.
2020-10-08 14:37:39 -04:00
```yaml
name: containerd
on:
push:
jobs:
containerd:
runs-on: ubuntu-latest
steps:
2020-10-23 16:51:59 -04:00
-
2020-10-08 14:37:39 -04:00
name: Checkout
2022-05-28 12:36:30 -04:00
uses: actions/checkout@v3
2020-10-08 14:37:39 -04:00
-
name: Set up QEMU
2023-09-12 04:12:12 -04:00
uses: docker/setup-qemu-action@v3
2020-10-08 14:37:39 -04:00
-
name: Set up Docker Buildx
2023-09-12 04:12:12 -04:00
uses: docker/setup-buildx-action@v3
2020-10-08 14:37:39 -04:00
with:
buildkitd-flags: --debug
-
name: Set up containerd
2022-05-28 12:36:30 -04:00
uses: crazy-max/ghaction-setup-containerd@v2
2020-10-08 14:37:39 -04:00
-
name: Build Docker image
2023-09-12 04:12:12 -04:00
uses: docker/build-push-action@v5
2020-10-08 14:37:39 -04:00
with:
context: .
2021-02-17 12:53:15 -05:00
platforms: linux/amd64,linux/arm64
2020-10-08 14:37:39 -04:00
tags: docker.io/user/app:latest
outputs: type=oci,dest=/tmp/image.tar
-
name: Import image in containerd
run: |
sudo ctr i import --base-name docker.io/user/app --digests --all-platforms /tmp/image.tar
-
name: Push image with containerd
run: |
sudo ctr --debug i push --user "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" docker.io/user/app:latest
```
2021-08-05 02:09:50 -04:00
## `repository name must be lowercase`
You may encounter this issue if you're using `github.repository` as a repo slug
in your tag:
```
#6 exporting to image
#6 exporting layers
#6 exporting layers 1.2s done
#6 exporting manifest sha256:b47f7dfb97b89ccd5de553af3c8cd94c4795884cbe5693e93946b1d95a7b1d12 0.0s done
#6 exporting config sha256:995e93fab8196893192f08a38deea6769dc4d98f86cf705eccc24ec96a3e271c 0.0s done
#6 ERROR: invalid reference format: repository name must be lowercase
------
> exporting to image:
------
error: failed to solve: invalid reference format: repository name must be lowercase
```
or a cache reference:
```
#10 importing cache manifest from ghcr.io/My-Org/repo:main
#10 ERROR: invalid reference format: repository name must be lowercase
```
To fix this issue you can use our [metadata action ](https://github.com/docker/metadata-action )
2021-10-02 12:37:02 -04:00
to generate sanitized tags:
```yaml
- name: Docker meta
id: meta
2022-05-05 13:24:32 -04:00
uses: docker/metadata-action@v4
2021-10-02 12:37:02 -04:00
with:
images: ghcr.io/${{ github.repository }}
tags: latest
- name: Build and push
2023-09-12 04:12:12 -04:00
uses: docker/build-push-action@v5
2021-10-02 12:37:02 -04:00
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
```
Or a dedicated step to sanitize the slug:
2021-08-05 02:09:50 -04:00
```yaml
- name: Sanitize repo slug
2022-05-28 12:36:30 -04:00
uses: actions/github-script@v6
2021-08-05 02:09:50 -04:00
id: repo_slug
with:
result-encoding: string
2021-10-02 12:37:02 -04:00
script: return 'ghcr.io/${{ github.repository }}'.toLowerCase()
2021-08-05 02:09:50 -04:00
- name: Build and push
2023-09-12 04:12:12 -04:00
uses: docker/build-push-action@v5
2021-08-05 02:09:50 -04:00
with:
context: .
push: true
tags: ${{ steps.repo_slug.outputs.result }}:latest
```
2023-07-03 03:01:27 -04:00
## Image not loaded
Sometimes when your workflows are heavy consumers of disk storage, it can happen that build-push-action declares that the built image is loaded, but then not found in the following workflow steps.
- You can use the following solution as workaround, to free space on disk before building docker image using the following workflow step
```yaml
# Free disk space
- name: Free Disk space
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
```
- Another workaround can be to call `docker/setup-buildx-action` with docker driver
```yaml
name: Set up Docker Buildx
2023-09-12 04:12:12 -04:00
uses: docker/setup-buildx-action@v3
2023-07-03 03:01:27 -04:00
with:
driver: docker
```
More details in the [related issue ](https://github.com/docker/build-push-action/issues/321 )