go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.11k stars 5.32k forks source link

[ContainerRegistry] Internal server error on `docker push <image_name>` #31215

Open oxbee opened 1 month ago

oxbee commented 1 month ago

Description

I want to use Gitea Packages as a Docker registry for one of my repos.

> cat Dockerfile
FROM busybox
CMD ["echo", "Hello Gitea registry! v2"]

> docker login gitea.djmil.dev --username djmil --password-stdin
Login Succeeded

> docker build -t gitea.djmil.dev/djmil/super_unique_version_42 .
[+] Building 1.8s (5/5) FINISHED

> docker push gitea.djmil.dev/djmil/dtest:super_unique_version_42
The push refers to repository [gitea.djmil.dev/djmil/dtest]
ec562eabd705: Pushed
bdb421fc0f9e: Pushed
failed commit on ref "manifest-sha256:5a73daa7ed0f7b9052fa0ea0143ef0f54c8f654f55ae1e1dccc5578e504efb92": unexpected status from PUT request to https://gitea.djmil.dev/v2/djmil/dtest/manifests/super_unique_version_42: 500 Internal Server Error

The cause of an error seems to be this line:

manifest.go:368:createPackageAndVersion() [E] Error inserting package: Error 1062 (23000): Duplicate entry '1-super_unique_version_42' for key 'package_version.UQE_package_version_s'

Non the less, the image seems to appear on the server. It also seems that most of the times I'am able to docker pull it..

Gitea Version

1.22

Can you reproduce the bug on the Gitea demo site?

No (not supported)

Log Gist

https://gist.github.com/oxbee/40ec1dce3a2cba34066f3a72a88335ab

Screenshots

image

Git Version

the one shipped with docker image

Operating System

MacOS Ventura 13.6.7

How are you running Gitea?

Official docker compose file with zero tweaks

Database

MySQL/MariaDB

kemzeb commented 1 month ago

This looks similar to #30973

oxbee commented 1 month ago

As stated in #27640, the bug seems to be relayed to MacOS docker client.

A functional workaround is to build an image without Provenance attestations:

docker build --provenance false -t gitea.djmil.dev/djmil/dtest:no_provenance .

And here is my little image with all it's layers 🥳 image

oxbee commented 1 month ago

Until the bug solved, maybe it worth mentioning this workaround as known bugs in the Container Registry documentation? @kemzeb is this a thing at the project? If yes, i would gladly do it.

Any way, i do hope people would be able google this workaround report by keywords:

"createPackageAndVersion() [E] Error inserting package: Error 1062 (23000): Duplicate entry 'some_tag_name' for key 'package_version.UQE_package_version_s'"

kemzeb commented 1 month ago

Until the bug solved, maybe it worth mentioning this workaround as known bugs in the Container Registry documentation? @kemzeb is this a thing at the project? If yes, i would gladly do it.

Looking at the Gitea documentation and the source, this does not appear to be a common practice.

If you wish, you could either discuss this on Discord or send a quick PR editing this page to see what others think about adding this section.